Commit f8eee83515032eca5e50d668ced44194eac6e36e

Authored by Jay Berkenbilt
1 parent 8dcf6da2

Expose QPDFArgParser::usage

include/qpdf/QPDFArgParser.hh
... ... @@ -150,6 +150,12 @@ class QPDFArgParser
150 150 QPDF_DLL
151 151 void insertCompletion(std::string const&);
152 152  
  153 + // Throw a Usage exception with the given message. In completion
  154 + // mode, this just exits to prevent errors from partial commands
  155 + // or other error messages from messing up completion.
  156 + QPDF_DLL
  157 + void usage(std::string const& message);
  158 +
153 159 private:
154 160 struct OptionEntry
155 161 {
... ... @@ -174,7 +180,6 @@ class QPDFArgParser
174 180 void argCompletionBash();
175 181 void argCompletionZsh();
176 182  
177   - void usage(std::string const& message);
178 183 void checkCompletion();
179 184 void handleArgFileArguments();
180 185 void handleBashArguments();
... ...
libqpdf/QPDFJob_argv.cc
... ... @@ -2174,15 +2174,7 @@ ArgParser::argEndCopyAttachments()
2174 2174 void
2175 2175 ArgParser::usage(std::string const& message)
2176 2176 {
2177   - if (this->ap.isCompleting())
2178   - {
2179   - // This will cause bash to fall back to regular file completion.
2180   - exit(0);
2181   - }
2182   - else
2183   - {
2184   - throw QPDFArgParser::Usage(message);
2185   - }
  2177 + this->ap.usage(message);
2186 2178 }
2187 2179  
2188 2180 std::vector<int>
... ...