Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

KDB Complete: Minor Issues #1296

Closed
3 tasks
sanssecours opened this issue Jan 29, 2017 · 7 comments
Closed
3 tasks

KDB Complete: Minor Issues #1296

sanssecours opened this issue Jan 29, 2017 · 7 comments

Comments

@sanssecours
Copy link
Member

sanssecours commented Jan 29, 2017

General Description

Recently I continued my work on completion commands for Fish. I incorporated kdb complete to generate completions for the current namespace. However, the subcommand complete does not work as expected in some situations. The following list summarizes some of the issues I found:

  • Completion of first level of namespace does not work
  • Provide initial completions for the root level of the namespace
  • Make information about number of keys/leaf optional

.

Completion of First Level of Namespace Does Not Work

Steps to Reproduce the Issue

Enter the following command in a Terminal window:

kdb complete us

.

Expected Result

I expected that the command would show the following completion (or something similar):

user

.

Actual Result

The command fails showing the following output:

Invalid arguments passed: us is not a valid keyname

For absolute keys (starting without '/'), please note that only one of the predefined namespaces can be used (see 'man elektra-namespaces').
Please also ensure that the path is separated by a '/'.
An example for a valid absolute key is user/a/key, and for a valid cascading key /a/key.

Usage: kdb complete <path>

Show suggestions how the current name could be completed.
Suggestions will include existing key names, path segments of existing key names and mountpoints.
Additionally, the output will indicate wheter the given path is a node or a leaf in the hierarchy of keys.
-d --debug               Give debug information or ask debug questions (in interactive mode).
-H --help                Show the man page.
-m --min-depth           Specify the minimum depth of completion suggestions (0 by default), exclusive.
-M --max-depth           Specify the maximum depth of completion suggestions (unlimited by default, 1 to show only the next level), inclusive.
-p --profile <name>      Use a different profile for kdb configuration
-v --verbose             Explain what is happening.
-V --version             Print version info.
-0 --null                Use binary 0 termination.

.

Provide Initial Completions for the Root Level of the Namespace

Steps to Reproduce the Issue

  1. Start with a clean configuration

  2. Enter the following commands in a Terminal window:

    kdb set user/level1 test
    #> Create a new key user/level1 with string test
    kdb set user/level1/level2 test
    #> Create a new key user/level1/level2 with string test
    kdb ls user
    #> user/level1
    #> user/level1/level2

    .

  3. Enter the following command

    kdb complete --max-depth=1

    .

Expected Result

I would expect, that the command would complete the first level of the namespace and therefore output the following (or something similar):

system
user

.

Actual Result

The command fails printing the following error message:

kdb complete --max-depth=1
Invalid arguments passed: wrong number of arguments, 1 needed

Usage: kdb complete <path>

Show suggestions how the current name could be completed.
Suggestions will include existing key names, path segments of existing key names and mountpoints.
Additionally, the output will indicate wheter the given path is a node or a leaf in the hierarchy of keys.
-d --debug               Give debug information or ask debug questions (in interactive mode).
-H --help                Show the man page.
-m --min-depth           Specify the minimum depth of completion suggestions (0 by default), exclusive.
-M --max-depth           Specify the maximum depth of completion suggestions (unlimited by default, 1 to show only the next level), inclusive.
-p --profile <name>      Use a different profile for kdb configuration
-v --verbose             Explain what is happening.
-V --version             Print version info.
-0 --null                Use binary 0 termination.

Make Information About Number of Keys/Leafs optional

While I am pretty sure there is a valid reason why kdb complete also prints information about the number of subkeys, the Fish completion commands do not use this information at all. In fact the current completion commands strips this information using sed. It would be really nice if kdb complete could only print the information about the number of subkeys if we specify the switch -v.

System Information

  • Elektra Version: master
@markus2330
Copy link
Contributor

markus2330 commented Jan 29, 2017

Thanks you, this is, as always, an excellent bug report!

kdb complete us

Ok, definitely a bug, should complete to available namespaces.

max-depth

Why do you want a cascading key to be completed to namespaces?
I would even argue it should complete to /level1?

Btw. why do you need max-depth in the auto-completion?
Do you prefer to complete every level individually?

Make Information About Number of Keys/Leafs optional

Maybe we should have a way to specify which of these 3 columns are needed with -123. (As in kdb mount)

Can you also create a PR with your current state of the fish auto-completion?

@sanssecours
Copy link
Member Author

max-depth

Why do you want a cascading key to be completed to namespaces?

Do you mean kdb complete --max-depth=1 / here? If the answer to this question is yes: I just wanted to determine an initial completion for the namespace. Since kdb complete without any additional arguments fails, I assumed kdb complete / would return completions for the root of Elektra‘s database (e.g. system, user, …). You are right though, the current behaviour of kdb complete / makes sense. I updated my initial comment accordingly.

Btw. why do you need max-depth in the auto-completion?
Do you prefer to complete every level individually?

Yes, currently I want to write code that just completes a single level. I assume that there are a lot of situations, where completing multiple levels would not be something we want. For example, even if the user namespace contains a single leaf

user/me/without/you/catch/for/us/the/foxes/leaf

, then it would still make sense to offer partial completions for a command like kdb ls. If we really want the completion user/me/without/you/catch/for/us/the/foxes/leaf, then we would just have to press multiple times.

Maybe we should have a way to specify which of these 3 columns are needed with -123. (As in kdb mount)

I think that makes sense if somebody wants this feature. Currently I can not think of a situation where this would be useful for the Fish completion commands though.

Can you also create a PR with your current state of the fish auto-completion?

I will do that after I am more happy with the current state of the completion commands.

@e1528532
Copy link
Contributor

Thanks for the report, you are right i haven't thought about initial namespace completion yet thus its not included. I'll add it, it makes sense to have that.

I also think that it makes sense to always only complete the next level.

@reox what do you think of listing the kind (node/leaf) and the number of children only when using -v? Do you need it per default for your completions? I think it makes sense to display it only when using -v, as is this is already some advanced information which is probably not necessary for normal completion.

@reox
Copy link
Contributor

reox commented Jan 30, 2017

the number of nodes/leafs is probably not needed in the completion anyways. So having it only on -v is totaly fine for me!

@markus2330
Copy link
Contributor

@reox the number is from your specification in #1167 🙄

Why not having
user/abc/ for non-leaf
user/abc for leaf

then we do not need multi-column at all?

@reox
Copy link
Contributor

reox commented Jan 30, 2017

maybe I had something in mind, i do not remember anymore... sorry :/

the trailing / looks good, then you also do not need the leaf/node specifier

@e1528532
Copy link
Contributor

See my changes in #1310 :
kdb complete will display every possible completion, including namespaces
kdb complete --max-depth=1 will display the namespaces (they are fixed currently, right?)
kdb complete us --max-depth=1 will complete to user/
information ab out leaf/nodes is only printed out when using -v now

@e1528532 e1528532 mentioned this issue Jan 30, 2017
27 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants