Commit f8eee83515032eca5e50d668ced44194eac6e36e
1 parent
8dcf6da2
Expose QPDFArgParser::usage
Showing
2 changed files
with
7 additions
and
10 deletions
include/qpdf/QPDFArgParser.hh
| @@ -150,6 +150,12 @@ class QPDFArgParser | @@ -150,6 +150,12 @@ class QPDFArgParser | ||
| 150 | QPDF_DLL | 150 | QPDF_DLL |
| 151 | void insertCompletion(std::string const&); | 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 | private: | 159 | private: |
| 154 | struct OptionEntry | 160 | struct OptionEntry |
| 155 | { | 161 | { |
| @@ -174,7 +180,6 @@ class QPDFArgParser | @@ -174,7 +180,6 @@ class QPDFArgParser | ||
| 174 | void argCompletionBash(); | 180 | void argCompletionBash(); |
| 175 | void argCompletionZsh(); | 181 | void argCompletionZsh(); |
| 176 | 182 | ||
| 177 | - void usage(std::string const& message); | ||
| 178 | void checkCompletion(); | 183 | void checkCompletion(); |
| 179 | void handleArgFileArguments(); | 184 | void handleArgFileArguments(); |
| 180 | void handleBashArguments(); | 185 | void handleBashArguments(); |
libqpdf/QPDFJob_argv.cc
| @@ -2174,15 +2174,7 @@ ArgParser::argEndCopyAttachments() | @@ -2174,15 +2174,7 @@ ArgParser::argEndCopyAttachments() | ||
| 2174 | void | 2174 | void |
| 2175 | ArgParser::usage(std::string const& message) | 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 | std::vector<int> | 2180 | std::vector<int> |