| 33 | const int Options::OVERWRITE_FORCE = 2; |
| 34 | |
| 35 | static void |
| 36 | processOptions(std::list<boost::program_options::options_description> &pack, |
| 37 | boost::program_options::options_description &visible_options, |
| 38 | boost::program_options::positional_options_description |
| 39 | &positional_options) { |
| 40 | using std::string; |
| 41 | using std::vector; |
| 42 | using namespace boost::program_options; |
| 43 | |
| 44 | options_description info_opts("Information Options"); |
| 45 | info_opts.add_options()("version,v", "Display the version.")( |
| 46 | "help,h", "View detailed help."); |
| 47 | pack.push_back(info_opts); |
| 48 | visible_options.add(info_opts); |
| 49 | |
| 50 | options_description main_opts("Main Options"); |
| 51 | main_opts.add_options()("delay,d", value<string>()->default_value("100"), |
| 52 | "Default frame delay [in miliseconds or fractions of " |
| 53 | "a second], default is 100.")( |
| 54 | "loops,l", value<int>()->default_value(0), |
| 55 | "Number of loops. Use 0 [the default] for infinite loops.")( |
| 56 | "file,f", value<string>(), |
| 57 | "Loads an XML or JSON animation directive file.")( |
| 58 | "skip,s", "Skip the first frame. When animation is not supported the " |
| 59 | "first frame is shown.")( |
| 60 | "disassemble,D", value<string>(), |
| 61 | "Specifies Disassemble file (Then, can NOT specify other files)")( |
| 62 | "output,o", value<string>(), |
| 63 | "Specifies Output File (Then, 1st argument is NOT output-file)")( |
| 64 | "json,j", value<string>()->implicit_value("animation.json"), |
| 65 | "Specifies output json file.")( |
| 66 | "xml,x", value<string>()->implicit_value("animation.xml"), |
| 67 | "Specifies output xml file."); |
| 68 | pack.push_back(main_opts); |
| 69 | visible_options.add(main_opts); |
| 70 | |
| 71 | options_description overwrite_opts("Overwrite Options"); |
| 72 | overwrite_opts.add_options()("nooverwrite,n", new multiple_untyped_value(), |
| 73 | "exit when overwrite.")( |
| 74 | "interactive,i", new multiple_untyped_value(), |
| 75 | "prompt before overwrite. (default)")("force,F", |
| 76 | new multiple_untyped_value(), |
| 77 | "always overwrites existing file."); |
| 78 | pack.push_back(overwrite_opts); |
| 79 | visible_options.add(overwrite_opts); |
| 80 | |
| 81 | options_description hidden_opts("Hidden options"); |
| 82 | hidden_opts.add_options()("files", value<vector<string>>(), |
| 83 | "a list files to be turned into frames"); |
| 84 | pack.push_back(hidden_opts); |
| 85 | positional_options.add("files", -1); |
| 86 | } |
| 87 | |
| 88 | Options::Options(int argc, char **argv) |
| 89 | : overwrite_mode(OVERWRITE_INTERACTIVE) { |