@@ -32,10 +32,10 @@ namespace options {
32
32
static llvm::cl::OptionCategory Category (" swift-symbolgraph-extract Options" );
33
33
34
34
static llvm::cl::opt<std::string>
35
- ModuleName (" module-name" , llvm::cl::desc(" Name of the module to extract" ), llvm::cl::cat(Category));
35
+ ModuleName (" module-name" , llvm::cl::desc(" Name of the module to extract (Required) " ), llvm::cl::cat(Category));
36
36
37
37
static llvm::cl::list<std::string>
38
- FrameworkSearchPaths (" F" , llvm::cl::desc(" add a directory to the framework search paths" ), llvm::cl::ZeroOrMore,
38
+ FrameworkSearchPaths (" F" , llvm::cl::desc(" Add a directory to the framework search paths" ), llvm::cl::ZeroOrMore,
39
39
llvm::cl::cat(Category));
40
40
41
41
static llvm::cl::list<std::string>
@@ -54,7 +54,7 @@ SDK("sdk", llvm::cl::desc("Path to the SDK"),
54
54
llvm::cl::cat(Category));
55
55
56
56
static llvm::cl::opt<std::string>
57
- Target (" target" , llvm::cl::desc(" Target triple" ),
57
+ Target (" target" , llvm::cl::desc(" Target triple (Required) " ),
58
58
llvm::cl::cat(Category));
59
59
60
60
static llvm::cl::opt<std::string>
@@ -67,9 +67,29 @@ static llvm::cl::opt<std::string>
67
67
MinimumAccessLevel (" minimum-access-level" , llvm::cl::desc(" Include symbols with this access level or more" ), llvm::cl::cat(Category));
68
68
69
69
static llvm::cl::opt<std::string>
70
- OutputPath (" o" , llvm::cl::desc(" Symbol Graph JSON Output Path" ), llvm::cl::cat(Category));
70
+ OutputPath (" o" , llvm::cl::desc(" Symbol Graph JSON Output Path (Required) " ), llvm::cl::cat(Category));
71
71
} // end namespace options
72
72
73
+ static bool argumentsAreValid () {
74
+ bool Valid = true ;
75
+ if (options::Target.empty ()) {
76
+ llvm::errs () << " Required -target option is missing\n " ;
77
+ Valid = false ;
78
+ }
79
+
80
+ if (options::ModuleName.empty ()) {
81
+ llvm::errs () << " Required -module-name argument is missing\n " ;
82
+ Valid = false ;
83
+ }
84
+
85
+ if (options::OutputPath.empty ()) {
86
+ llvm::errs () << " Required -o argument is missing\n " ;
87
+ Valid = false ;
88
+ }
89
+
90
+ return Valid;
91
+ }
92
+
73
93
int swift_symbolgraph_extract_main (ArrayRef<const char *> Args, const char *Argv0, void *MainAddr) {
74
94
INITIALIZE_LLVM ();
75
95
@@ -79,8 +99,18 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
79
99
SmallVector<const char *, 8 > ArgsWithArgv0 { Argv0 };
80
100
ArgsWithArgv0.append (Args.begin (), Args.end ());
81
101
102
+ if (Args.empty ()) {
103
+ ArgsWithArgv0.push_back (" -help" );
104
+ }
105
+
82
106
llvm::cl::ParseCommandLineOptions (ArgsWithArgv0.size (),
83
- llvm::makeArrayRef (ArgsWithArgv0).data (), " Swift Symbol Graph Extractor\n " );
107
+ llvm::makeArrayRef (ArgsWithArgv0).data (),
108
+ " Swift Symbol Graph Extractor\n " );
109
+
110
+ if (!argumentsAreValid ()) {
111
+ llvm::cl::PrintHelpMessage ();
112
+ return EXIT_FAILURE;
113
+ }
84
114
85
115
CompilerInvocation Invocation;
86
116
0 commit comments