Permalink
Browse files

configure-cabal-project, open-cabal-project:

allow passing an array of args instead of a string
containing many args so no escaping has to be done.

implementation of decodeExtraArgs provided by Thomas Schilling
  • Loading branch information...
1 parent 049e911 commit ca42d2a30bc4129a065b0141f9e6fd4cd30b9698 @MarcWeber MarcWeber committed Jul 21, 2009
Showing with 13 additions and 6 deletions.
  1. +2 −2 emacs/scion.el
  2. +11 −4 server/Scion/Server/Commands.hs
View
@@ -1912,7 +1912,7 @@ EXTRA-ARGS is a string of command line flags."
(lexical-let ((root-dir root-dir))
(scion-eval-async `(open-cabal-project :root-dir ,(expand-file-name root-dir)
:dist-dir ,rel-dist-dir
- :extra-args ,extra-args)
+ :extra-args ,(split-string extra-args))
(lambda (x)
(setq scion-project-root-dir root-dir)
(message (format "Cabal project loaded: %s" x)))))
@@ -1945,7 +1945,7 @@ EXTRA-ARGS is a string of command line flags."
(lexical-let ((root-dir root-dir))
(scion-eval-async `(configure-cabal-project :root-dir ,(expand-file-name root-dir)
:dist-dir ,rel-dist-dir
- :extra-args ,extra-args)
+ :extra-args ,(split-string extra-args))
(lambda (x)
(setq scion-project-root-dir root-dir)
(message (format "Cabal project loaded: %s" x))))))
@@ -272,10 +272,10 @@ cmdOpenCabalProject =
Cmd "open-cabal-project" $
reqArg' "root-dir" fromJSString <&>
optArg' "dist-dir" ".dist-scion" fromJSString <&>
- optArg' "extra-args" "" fromJSString $ worker
+ optArg' "extra-args" [] decodeExtraArgs $ worker
where
worker root_dir dist_dir extra_args = do
- openOrConfigureCabalProject root_dir dist_dir (words extra_args)
+ openOrConfigureCabalProject root_dir dist_dir extra_args
preprocessPackage dist_dir
(toJSString . display . PD.package) `fmap` currentCabalPackage
@@ -284,13 +284,20 @@ cmdConfigureCabalProject =
Cmd "configure-cabal-project" $
reqArg' "root-dir" fromJSString <&>
optArg' "dist-dir" ".dist-scion" fromJSString <&>
- optArg' "extra-args" "" fromJSString $ cmd
+ optArg' "extra-args" [] decodeExtraArgs $ cmd
where
cmd path rel_dist extra_args = do
- configureCabalProject path rel_dist (words extra_args)
+ configureCabalProject path rel_dist extra_args
preprocessPackage rel_dist
(toJSString . display . PD.package) `fmap` currentCabalPackage
+decodeExtraArgs :: JSValue -> [String]
+decodeExtraArgs JSNull = []
+decodeExtraArgs (JSString s) =
+ words (fromJSString s) -- TODO: check shell-escaping
+decodeExtraArgs (JSArray arr) =
+ [ fromJSString s | JSString s <- arr ]
+
instance JSON Component where
readJSON (JSObject obj)
| Ok JSNull <- lookupKey obj "library" = return Library

0 comments on commit ca42d2a

Please sign in to comment.