You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
libelektra-opts does support parameter arguments. A "parameter argument" is a CLI arguments that is neither an option, an option argument nor a subcommand, e.g. in kdb --color never get user:/foo only user:/foo is a parameter argument.
For example, the spec above will load the first parameter argument into from, the second into to and the rest into more/#0, more/#1 etc. However, by using args/index = N we also introduce the restriction that there must be at least N parameter arguments. This not always what we want.
Proposal
libelektra-opts should also accept fewer than N parameter arguments, even if args/index = N is specified. The additional args = indexed keys should be left unset.
However, producing the old behaviour should still be possible. I have two ideas for achieving this.
The second one is a bit simpler IMO, but introduces new syntax, while the first one reuses the existing require metakey.
Version 1
It should still be required that: If args/index = N is used, args/index = M for all0 <= M < N must also be part of the specification.
If the metakey require is set on a specification key with args = indexed, there must be parameter argument to assign to this key.
Following from the above, when require is set on a key with args/index = N the old behaviour is restored up to N, i.e. there must be at least N parameter arguments. To make this more obvious, libelektra-opts should enforce that: If args/index = N is used on a key with require, the metakey require must also be set on all keys with args/index = M with 0 <= M < N.
Version 2
On the same keys which may already use the command metakey, a new args/min = N metakey can be used. If set, this sub-command requires at least N parameter arguments.
If args/min = N is not used, all parameter arguments are optional.
Personally, I prefer the second option, because it is much easier to use and probably also easier to implement (just read the metakey if it exists and check the against the number of unused args).
The text was updated successfully, but these errors were encountered:
libelektra-opts
does support parameter arguments. A "parameter argument" is a CLI arguments that is neither an option, an option argument nor a subcommand, e.g. inkdb --color never get user:/foo
onlyuser:/foo
is a parameter argument.For example, the spec above will load the first parameter argument into
from
, the second intoto
and the rest intomore/#0
,more/#1
etc. However, by usingargs/index = N
we also introduce the restriction that there must be at leastN
parameter arguments. This not always what we want.Proposal
libelektra-opts
should also accept fewer thanN
parameter arguments, even ifargs/index = N
is specified. The additionalargs = indexed
keys should be left unset.However, producing the old behaviour should still be possible. I have two ideas for achieving this.
The second one is a bit simpler IMO, but introduces new syntax, while the first one reuses the existing
require
metakey.Version 1
args/index = N
is used,args/index = M
for all0 <= M < N
must also be part of the specification.require
is set on a specification key withargs = indexed
, there must be parameter argument to assign to this key.require
is set on a key withargs/index = N
the old behaviour is restored up toN
, i.e. there must be at leastN
parameter arguments. To make this more obvious,libelektra-opts
should enforce that: Ifargs/index = N
is used on a key withrequire
, the metakeyrequire
must also be set on all keys withargs/index = M
with0 <= M < N
.Version 2
command
metakey, a newargs/min = N
metakey can be used. If set, this sub-command requires at leastN
parameter arguments.args/min = N
is not used, all parameter arguments are optional.Personally, I prefer the second option, because it is much easier to use and probably also easier to implement (just read the metakey if it exists and check the against the number of unused args).
The text was updated successfully, but these errors were encountered: