recognize --option in addition to -option for most things
Mark Tiefenbruck mark@fluxbox.org
4 files changed,
34 insertions(+),
32 deletions(-)
M
ChangeLog
→
ChangeLog
@@ -1,9 +1,11 @@
(Format: Year/Month/Day) Changes for 1.1.2 *08/10/04: + * Recognize --option in addition to -option for long option names (Mark) + main.cc util/fbsetroot.cc util/fbrun/main.cc * Add -print option to fbrun that sends the result to stdout instead of running it (Mark) - util/FbRun/main.cc FbRun.cc/hh + util/fbrun/main.cc FbRun.cc/hh * Fix CustomMenu and ClientMenu commands from fluxbox-remote (Mark) Screen.cc * Break emacs-style keychains after one invalid key has been pressed (Mark)
M
src/main.cc
→
src/main.cc
@@ -191,7 +191,7 @@
int i; for (i = 1; i < argc; ++i) { string arg(argv[i]); - if (arg == "-rc") { + if (arg == "-rc" || arg == "--rc") { // look for alternative rc file to use if ((++i) >= argc) {@@ -201,7 +201,7 @@ exit(EXIT_FAILURE);
} rc_file = argv[i]; - } else if (arg == "-display") { + } else if (arg == "-display" || arg == "--display") { // check for -display option... to run on a display other than the one // set by the environment variable DISPLAY@@ -220,19 +220,19 @@ "warning: couldn't set environment variable 'DISPLAY'",
"")<<endl; perror("putenv()"); } - } else if (arg == "-version" || arg == "-v") { + } else if (arg == "-version" || arg == "-v" || arg == "--version") { // print current version string cout << "Fluxbox " << __fluxbox_version << " : (c) 2001-2008 Fluxbox Team " << endl << endl; exit(EXIT_SUCCESS); - } else if (arg == "-log") { + } else if (arg == "-log" || arg == "--log") { if (++i >= argc) { cerr<<_FB_CONSOLETEXT(main, LOGRequiresArg, "error: '-log' needs an argument", "")<<endl; exit(EXIT_FAILURE); } log_filename = argv[i]; - } else if (arg == "-sync") { + } else if (arg == "-sync" || arg == "--sync") { xsync = true; - } else if (arg == "-help" || arg == "-h") { + } else if (arg == "-help" || arg == "-h" || arg == "--help") { // print program usage and command line options printf(_FB_CONSOLETEXT(main, Usage, "Fluxbox %s : (c) %s Henrik Kinnunen\n"@@ -250,17 +250,17 @@
"Main usage string. Please lay it out nicely. There is one %s that is given the version").c_str(), __fluxbox_version, "2001-2008"); exit(EXIT_SUCCESS); - } else if (arg == "-info" || arg == "-i") { + } else if (arg == "-info" || arg == "-i" || arg == "--info") { showInfo(cout); exit(EXIT_SUCCESS); - } else if (arg == "-list-commands") { + } else if (arg == "-list-commands" || arg == "--list-commands") { FbTk::CommandParser<void>::CreatorMap cmap = FbTk::CommandParser<void>::instance().creatorMap(); FbTk::CommandParser<void>::CreatorMap::const_iterator it = cmap.begin(); const FbTk::CommandParser<void>::CreatorMap::const_iterator it_end = cmap.end(); for (; it != it_end; ++it) cout << it->first << endl; exit(EXIT_SUCCESS); - } else if (arg == "-verbose") { + } else if (arg == "-verbose" || arg == "--verbose") { FbTk::ThemeManager::instance().setVerbose(true); } }
M
util/fbrun/main.cc
→
util/fbrun/main.cc
@@ -86,27 +86,28 @@ string display_name; // name of the display connection
string history_file("~/.fluxbox/fbrun_history"); // command history file // parse arguments for (int i=1; i<argc; i++) { - if (strcmp(argv[i], "-font") == 0 && i+1 < argc) { + string arg = argv[i]; + if ((arg == "-font" || arg == "--font") && i+1 < argc) { fontname = argv[++i]; - } else if (strcmp(argv[i], "-print") == 0) { + } else if (arg == "-print" || arg == "--print") { print = true; - } else if (strcmp(argv[i], "-title") == 0 && i+1 < argc) { + } else if ((arg == "-title" || arg == "--title") && i+1 < argc) { title = argv[++i]; - } else if (strcmp(argv[i], "-text") == 0 && i+1 < argc) { + } else if ((arg == "-text" || arg == "--text") && i+1 < argc) { text = argv[++i]; - } else if (strcmp(argv[i], "-w") == 0 && i+1 < argc) { + } else if (arg == "-w" && i+1 < argc) { width = atoi(argv[++i]); set_width = true; - } else if (strcmp(argv[i], "-h") == 0 && i+1 < argc) { + } else if (arg == "-h" && i+1 < argc) { height = atoi(argv[++i]); set_height = true; // mark true else the height of font will be used - } else if (strcmp(argv[i], "-display") == 0 && i+1 < argc) { + } else if ((arg == "-display" || arg == "--display") && i+1 < argc) { display_name = argv[++i]; - } else if (strcmp(argv[i], "-pos") == 0 && i+2 < argc) { + } else if ((arg == "-pos" || arg == "--pos") && i+2 < argc) { x = atoi(argv[++i]); y = atoi(argv[++i]); set_pos = true; - } else if (strcmp(argv[i], "-nearmouse") == 0) { + } else if (arg == "-nearmouse" || arg == "--nearmouse") { set_pos = true; near_mouse = true; } else if (strcmp(argv[i], "-fg") == 0 && i+1 < argc) {@@ -117,7 +118,7 @@ } else if (strcmp(argv[i], "-na") == 0) {
antialias = false; } else if (strcmp(argv[i], "-hf") == 0 && i+1 < argc) { history_file = argv[++i]; - } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) { + } else if (arg == "-h" || arg == "-help" || arg == "--help") { showUsage(argv[0]); exit(0); } else {
M
util/fbsetroot.cc
→
util/fbsetroot.cc
@@ -67,30 +67,29 @@
img_ctrl = new FbTk::ImageControl(screen); for (; i < argc; i++) { - if (! strcmp("-help", argv[i])) { + string arg = argv[i]; + if (arg == "-help" || arg == "--help" || arg == "-h") { usage(); - } else if ((! strcmp("-fg", argv[i])) || - (! strcmp("-foreground", argv[i])) || - (! strcmp("-from", argv[i]))) { + } else if (arg == "-fg" || arg == "-foreground" || + arg == "--foreground" || arg == "-from" || arg == "--from") { if ((++i) >= argc) usage(1); fore = argv[i]; - } else if ((! strcmp("-bg", argv[i])) || - (! strcmp("-background", argv[i])) || - (! strcmp("-to", argv[i]))) { + } else if (arg == "-bg" || arg == "-background" || + arg == "--background" || arg == "-to" || arg == "--to") { if ((++i) >= argc) usage(1); back = argv[i]; - } else if (! strcmp("-solid", argv[i])) { + } else if (arg == "-solid" || arg == "--solid") { if ((++i) >= argc) usage(1); fore = argv[i]; sol = true; - } else if (! strcmp("-mod", argv[i])) { + } else if (arg == "-mod" || arg == "--mod") { if ((++i) >= argc) usage(); mod_x = atoi(argv[i]);@@ -103,14 +102,14 @@ if (mod_y < 1)
mod_y = 1; mod = true; - } else if (! strcmp("-gradient", argv[i])) { + } else if (arg == "-gradient" || arg == "--gradient") { if ((++i) >= argc) usage(); grad = argv[i]; grd = true; - } else if (! strcmp("-display", argv[i])) { + } else if (arg == "-display" || arg == "--display") { // -display passed through tests earlier... we just skip it now i++;@@ -382,7 +381,7 @@
FbTk::NLSInit("fluxbox.cat"); for (; i < argc; i++) { - if (! strcmp(argv[i], "-display")) { + if (!strcmp(argv[i], "-display") || !strcmp(argv[i], "--display")) { // check for -display option if ((++i) >= argc) {