[f-spot] Do the backwards compat args fix in C#.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] Do the backwards compat args fix in C#.
- Date: Mon, 14 Jun 2010 13:35:32 +0000 (UTC)
commit fd9c25cf65b329a75a97e4af467425489d00f0fe
Author: Ruben Vermeersch <ruben savanne be>
Date: Mon Jun 14 15:34:25 2010 +0200
Do the backwards compat args fix in C#.
The shell hack broke parameters with spaces in them. E.g.:
f-spot --view /home/ruben/Desktop/capetown\ area.png
src/f-spot.in | 21 ---------------------
src/main.cs | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 21 deletions(-)
---
diff --git a/src/f-spot.in b/src/f-spot.in
index 3b8227b..729b681 100644
--- a/src/f-spot.in
+++ b/src/f-spot.in
@@ -27,27 +27,6 @@ run_valgrind=false
run_strace=false
basedir_set=false
-#rewrite old options to new ones
-for arg in "$@";do
- case $arg in
- -h|-help|-usage) args+=(--help);;
- -V|-version) args+=(--version);;
- -versions) args+=(--versions);;
- -shutdown) args+=(--shutdown);;
- -b|-basedir) args+=(--basedir);;
- -p|-photodir) args+=(--photodir);;
- -i|-import) args+=(--import);;
- -v|-view) args+=(--view);;
- -slideshow) args+=(--slideshow);;
- *) args+=("$arg");;
- esac;
-done;
-args=${args[ ]}
-args=${args/photodir /photodir=}
-args=${args/basedir /basedir=}
-args=${args/import /import=}
-set -- $args
-
for arg in "$@"; do
case "x$arg" in
x--debug)
diff --git a/src/main.cs b/src/main.cs
index 78aa83a..27027bb 100644
--- a/src/main.cs
+++ b/src/main.cs
@@ -88,8 +88,51 @@ namespace FSpot
}
}
+ static string [] FixArgs (string [] args)
+ {
+ // Makes sure command line arguments are parsed backwards compatible.
+ var outargs = new List<string> ();
+ for (int i = 0; i < args.Length; i++) {
+ switch (args [i]) {
+ case "-h": case "-help": case "-usage":
+ outargs.Add ("--help");
+ break;
+ case "-V": case "-version":
+ outargs.Add ("--version");
+ break;
+ case "-versions":
+ outargs.Add ("--versions");
+ break;
+ case "-shutdown":
+ outargs.Add ("--shutdown");
+ break;
+ case "-b": case "-basedir":
+ outargs.Add ("--basedir=" + (i + 1 == args.Length ? String.Empty : args [++i]));
+ break;
+ case "-p": case "-photodir":
+ outargs.Add ("--photodir=" + (i + 1 == args.Length ? String.Empty : args [++i]));
+ break;
+ case "-i": case "-import":
+ outargs.Add ("--import=" + (i + 1 == args.Length ? String.Empty : args [++i]));
+ break;
+ case "-v": case "-view":
+ outargs.Add ("--view");
+ break;
+ case "-slideshow":
+ outargs.Add ("--slideshow");
+ break;
+ default:
+ outargs.Add (args [i]);
+ break;
+ }
+ }
+ return outargs.ToArray ();
+ }
+
static int Main (string [] args)
{
+ args = FixArgs (args);
+
Unix.SetProcessName (Defines.PACKAGE);
ThreadAssist.InitializeMainThread ();
@@ -109,6 +152,8 @@ namespace FSpot
FSpot.Global.PhotoUri = new SafeUri (Preferences.Get<string> (Preferences.STORAGE_PATH));
+ ApplicationContext.CommandLine = new CommandLineParser (args, 0);
+
if (ApplicationContext.CommandLine.ContainsStart ("help")) {
ShowHelp ();
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]