40ants / defmain

A helper to simplify command line arguments usage in Common Lisp
https://40ants.com/defmain/
30 stars 1 forks source link

Scoping of subcommands #5

Open alessiostalla opened 3 years ago

alessiostalla commented 3 years ago
(defmain (foo create) ...)
(defmain (bar create) ...)

It's not clear from the documentation, but the two will interfere even if they're different subcommands. Should one use symbols in different packages? E.g.

(defmain (foo my-cli-foo:create) ...)
(defmain (bar my-cli-bar:create) ...)

Or is there some way of decoupling the name of a subcommand from the word used to invoke it, e.g.,

(defmain (foo (create-foo "create")) ...)
(defmain (bar (create-bar "create")) ...)

In any case, the documentation ought to say something about this.

svetlyak40wt commented 3 years ago

Yeah, defmain and defcommand create a usual functions and using the same name will cause name conflict.

If you want, you can modify DEFCOMMAND macro and to introduce a COMMAND-NAME keyword argument, as I did for DEFMAIN's macro argument PROGRAM-NAME: https://40ants.com/defmain/#x-28DEFMAIN-3ADEFMAIN-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29

svetlyak40wt commented 3 years ago

Usually I'm using package inferred asdf systems and in this case each command will be defined in it's own file and have it's own package.

alessiostalla commented 3 years ago

If you want, you can modify DEFCOMMAND macro and to introduce a COMMAND-NAME keyword argument

Neat, that would do the trick, thanks. Do I need to do anything special to open a PR?