@@ -53,6 +53,11 @@ static llvm::cl::opt<std::string>
53
53
llvm::cl::desc (" Directory for the output file" ),
54
54
llvm::cl::cat(Category));
55
55
56
+ static llvm::cl::opt<std::string>
57
+ OutputFilename (" output-filename" ,
58
+ llvm::cl::desc (" Filename for the output file" ),
59
+ llvm::cl::cat(Category));
60
+
56
61
} // namespace options
57
62
58
63
int main (int argc, char *argv[]) {
@@ -62,18 +67,25 @@ int main(int argc, char *argv[]) {
62
67
llvm::cl::ParseCommandLineOptions (argc, argv,
63
68
" Swift `.def` to YAML Converter\n " );
64
69
65
- // The default language for localization is English
66
- std::string defaultLocaleCode = " en" ;
67
- llvm::SmallString<128 > LocalizedFilePath (options::OutputDirectory);
68
- llvm::sys::path::append (LocalizedFilePath, defaultLocaleCode);
69
- llvm::sys::path::replace_extension (LocalizedFilePath, " .yaml" );
70
+ llvm::SmallString<128 > LocalizedFilePath;
71
+ if (options::OutputFilename.empty ()) {
72
+ // The default language for localization is English
73
+ std::string defaultLocaleCode = " en" ;
74
+ LocalizedFilePath = options::OutputDirectory;
75
+ llvm::sys::path::append (LocalizedFilePath, defaultLocaleCode);
76
+ llvm::sys::path::replace_extension (LocalizedFilePath, " .yaml" );
77
+ } else {
78
+ LocalizedFilePath = options::OutputFilename;
79
+ }
70
80
71
81
std::error_code error;
72
82
llvm::raw_fd_ostream OS (LocalizedFilePath.str (), error,
73
83
llvm::sys::fs::F_None);
74
84
75
85
if (OS.has_error () || error) {
76
- llvm::errs () << LocalizedFilePath.str () << " does not exist\n " ;
86
+ llvm::errs () << " Error has occurred while trying to write to "
87
+ << LocalizedFilePath.str ()
88
+ << " with error code: " << error.message () << " \n " ;
77
89
return EXIT_FAILURE;
78
90
}
79
91
0 commit comments