Permalink
Browse files

[fix] serverArg: filter will only filter on real arguments, no on exe…

…cutable name
  • Loading branch information...
1 parent eecdac0 commit 71a4c120e713b8316a92c54a59d0a9cbb18e67a0 @Aqua-Ye Aqua-Ye committed Oct 1, 2012
Showing with 12 additions and 10 deletions.
  1. +1 −2 lib/plugins/unix/bslSys.ml
  2. +4 −1 lib/plugins/unix/bslSys.nodejs
  3. +7 −7 lib/stdlib/core/args/server_arg.opa
@@ -29,8 +29,7 @@ let caml_list_to_opa_list =
let argv () =
let args = Array.to_list Sys.argv in
ServerArg.set_argv (ServerArg.from_list (List.filter (fun a -> a == "--help") (ServerArg.to_list (ServerArg.get_argv()))));
- let caml_list = match args with [] -> [] | _0::args -> args in
- caml_list_to_opa_list Base.identity caml_list
+ caml_list_to_opa_list Base.identity args
(**
This is used by opa servers or qml applications to have access
@@ -21,7 +21,10 @@ fs.existsSync = fs.existsSync ? fs.existsSync : path.existsSync;
*/
function argv() {
var argv = process.argv, av = [];
- if (argv.length > 1) { argv.shift(); };
+ if (argv.length > 1) {
+ argv.shift(); // node
+ // argv.shift(); // exec name
+ };
for (var i = 0; i < process.argv.length; i++) {
if (process.argv[i] == "--help") av[av.length] = "--help";
};
@@ -1,5 +1,5 @@
/*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of Opa.
@@ -16,9 +16,9 @@ type ServerArg.instruction('a) = option(CommandLine.change_state('a))
ServerArg = {{
- @private sa_args = ServerReference.create(%%BslSys.argv%%():list(string))
- get_argv() = ServerReference.get(sa_args)
- set_argv(args) = ServerReference.set(sa_args,args)
+ @private sa_args = ServerReference.create(List.tail(%%BslSys.argv%%():list(string)))
+ @private get_args() = ServerReference.get(sa_args)
+ @private set_args(args) = ServerReference.set(sa_args,args)
bool_of_string(str:string) : option(bool) = Parser.try_parse(Rule.bool, str)
int_of_string(str:string) : option(int) = Parser.try_parse(Rule.integer, str)
@@ -66,7 +66,7 @@ ServerArg = {{
match
List.fold((x, res ->
match res with
- | {some=l} ->
+ | {some=l} ->
match parse([x]) with
| ({some=x}, [], []) -> {some=[x|l]}
| _ -> none
@@ -265,11 +265,11 @@ ServerArg = {{
do_args((acc0,[]),args0)
sa_filter(acc,parse) =
- args = get_argv()
+ args = get_args()
match parse(acc,args) with
| ({none}, _, _) -> acc
| ({some=acc}, skipped_args, args) ->
- do set_argv(List.append(skipped_args,args))
+ do set_args(List.append(skipped_args,args))
acc
filter(topic,args,init) =

0 comments on commit 71a4c12

Please sign in to comment.