Skip to content

Commit

Permalink
[fix] serverArg: filter will only filter on real arguments, no on exe…
Browse files Browse the repository at this point in the history
…cutable name
  • Loading branch information
Frederic Ye committed Oct 1, 2012
1 parent eecdac0 commit 71a4c12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lib/plugins/unix/bslSys.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion lib/plugins/unix/bslSys.nodejs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Expand Down
14 changes: 7 additions & 7 deletions lib/stdlib/core/args/server_arg.opa
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2011 MLstate
Copyright © 2011, 2012 MLstate
This file is part of Opa.
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) =
Expand Down

0 comments on commit 71a4c12

Please sign in to comment.