defmain icon indicating copy to clipboard operation
defmain copied to clipboard

Scoping of subcommands

Open alessiostalla opened this issue 3 years ago • 3 comments

(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.

alessiostalla avatar Jul 24 '21 15:07 alessiostalla

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 avatar Jul 26 '21 10:07 svetlyak40wt

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.

svetlyak40wt avatar Jul 26 '21 10:07 svetlyak40wt

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?

alessiostalla avatar Jul 27 '21 12:07 alessiostalla