@@ -11,11 +11,14 @@ opt_spec() ->
1111 " Install a Jupyter kernelspec for this backend" ,
1212 [
1313 {name , $n , " name" , string , " Install the kernel under this name "
14- " (defaults to the backend name"
14+ " (defaults to the backend name) "
1515 },
1616 {copy , $c , " copy" , boolean , " Copy the escript to make a standalone "
1717 " kernel" },
18- {node , undefined , " node" , string , " Remote node to run against" }
18+ {node , undefined , " node" , string , " Remote node to run against" },
19+ {sname , undefined , " sname" , string , " Short name for this node "
20+ " (defaults to the backend name" },
21+ {cookie , undefined , " cookie" , string , " Cookie" }
1922 ]
2023 }.
2124
@@ -24,20 +27,18 @@ exec({BName, Backend}, ParsedArgs, _Rest) ->
2427 application :ensure_all_started (jsx ),
2528
2629 % TODO: Default to BName_Node
27-
2830 Name = proplists :get_value (name , ParsedArgs , BName ),
2931 Copy = proplists :get_value (copy , ParsedArgs , false ),
3032
31- Args = #{ copy => Copy },
33+ Args = #{ copy => Copy , args => [] },
3234
33- Args1 = case proplists :get_value (node , ParsedArgs , undefined ) of
34- undefined ->
35- Args ;
36- Val ->
37- Args #{
38- args => [<<" --node" >>, jup_util :ensure_binary (Val )]
39- }
40- end ,
35+ Args1 = lists :foldl (
36+ fun (PName , A ) ->
37+ forward_arg (PName , ParsedArgs , A )
38+ end ,
39+ Args ,
40+ [node , sname , cookie ]
41+ ),
4142
4243 % TODO Parse rest and add to spec
4344
@@ -46,3 +47,16 @@ exec({BName, Backend}, ParsedArgs, _Rest) ->
4647 io :format (" Built kernel spec, storing~n " ),
4748 ierl_kernelspec :write (Name , Spec ),
4849 io :format (" Installed kernel ~s with backend ~s~n " , [Name , Backend ]).
50+
51+
52+ forward_arg (Name , ParsedArgs , Args ) ->
53+ case proplists :get_value (Name , ParsedArgs , undefined ) of
54+ undefined ->
55+ Args ;
56+ Val ->
57+ Param = jup_util :ensure_binary (io_lib :format (" --~p " , [Name ])),
58+ Args #{
59+ args => maps :get (args , Args , [])
60+ ++ [Param , jup_util :ensure_binary (Val )]
61+ }
62+ end .
0 commit comments