libelektra icon indicating copy to clipboard operation
libelektra copied to clipboard

elektraGetOptsHelpMessage docs/examples use 'opt/arg/name' instead of 'opt/arg/help'

Open hannes99 opened this issue 3 years ago • 4 comments

Steps to Reproduce the Problem

...
(ks, keyNew (baseKeyName "spec:/test/path", KEY_META, "description", "Some description",  \
                                            KEY_META, "opt", "p", \
                                            KEY_META, "opt/arg/name", "path", \
                                            KEY_META, "opt/long", "path", \
                                            KEY_META, "opt/arg", "required", KEY_END));  \
...
... elektraGetOpts (ks, argc, (const char **) argv, (const char **) environ, errorKey);
...
char * help = elektraGetOptsHelpMessage (errorKey, NULL, NULL);

The --help output ignores the specified opt/arg/name and always uses ARG instead.

Expected Result

OPTIONS
...
  -p path, --profile=path     Some description.
...

Actual Result

OPTIONS
...
  -p ARG, --profile=ARG       Some description.
...

hannes99 avatar Aug 10 '22 13:08 hannes99

Could you try with opt/arg/help instead?

I think that's what is actually used. See

https://github.com/ElektraInitiative/libelektra/blob/d57703bd1eaff0626fcfa8290773d68832085c4f/src/libs/opts/opts.c#L781-L783

https://github.com/ElektraInitiative/libelektra/blob/d57703bd1eaff0626fcfa8290773d68832085c4f/src/libs/opts/opts.c#L823

https://github.com/ElektraInitiative/libelektra/blob/d57703bd1eaff0626fcfa8290773d68832085c4f/src/libs/opts/opts.c#L925

https://github.com/ElektraInitiative/libelektra/blob/d57703bd1eaff0626fcfa8290773d68832085c4f/src/libs/opts/opts.c#L971-L992

kodebach avatar Aug 10 '22 14:08 kodebach

Actually, yes. I'll update the rm example in the tutorial[1], since /name is used there.

[1] https://www.libelektra.org/tutorials/command-line-options#examples

hannes99 avatar Aug 10 '22 14:08 hannes99

should I change the Issue title and description, or leave it?

hannes99 avatar Aug 10 '22 14:08 hannes99

I'll update the rm example in the tutorial

Please also check other docs, like examples/opts.c and examples/gopts.c

should I change the Issue title and description, or leave it?

I updated it.

kodebach avatar Aug 10 '22 14:08 kodebach