Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding long list -l format and hidden file support to secrets ls command #278

Open
aryanjassal opened this issue Sep 10, 2024 · 5 comments
Assignees
Labels
development Standard development

Comments

@aryanjassal
Copy link
Contributor

Specification

In the previous issue, #245 (ENG-358), listing the contents of a single directory was implemented instead of listing the contents of the entire vault. This issue now includes the remaining tasks for: long format listing, showing hidden files, using wildcards and specifying multiple paths.

The secrets ls command will list the contents of a directory.

There are 3 main features to support here.

  1. List in list format -l
  2. Include hidden files with -a
  3. Paths can support wildcards and globing.
  4. Multiple paths can be specified.
  5. stdin is ignored
Polykey/tmp/asd on  staging [?] 
❯ ls
asdasd  best  dir1  dir2  one  test  two

Polykey/tmp/asd on  staging [?] 
❯ ls -l
total 32
-rw-r--r-- 1 brian operators  8 Jul 11 11:18 asdasd
-rw-r--r-- 1 brian operators 15 Jul 11 11:18 best
drwxr-xr-x 2 brian operators  2 Jul 11 11:19 dir1
drwxr-xr-x 2 brian operators  2 Jul 11 11:19 dir2
-rw-r--r-- 1 brian operators  0 Jul 11 11:18 one
-rw-r--r-- 1 brian operators  5 Jul 11 11:18 test
-rw-r--r-- 1 brian operators  0 Jul 11 11:18 two

Polykey/tmp/asd on  staging [?] 
❯ ls -a
.  ..  asdasd  best  dir1  dir2  .hidden  one  test  two

Polykey/tmp/asd on  staging [?] 
❯ ls *est
best  test

Polykey/tmp/asd on  staging [?] 
❯ ls **/*     
asdasd  best  dir1/a  dir2/b  dir2/c  one  test  two

dir1:
a

dir2:
b  c

Polykey/tmp/asd on  staging [?] 
❯ ls -l **/*
-rw-r--r-- 1 brian operators  8 Jul 11 11:18 asdasd
-rw-r--r-- 1 brian operators 15 Jul 11 11:18 best
-rw-r--r-- 1 brian operators  0 Jul 11 11:42 dir1/a
-rw-r--r-- 1 brian operators  0 Jul 11 11:43 dir2/b
-rw-r--r-- 1 brian operators  0 Jul 11 11:43 dir2/c
-rw-r--r-- 1 brian operators  0 Jul 11 11:18 one
-rw-r--r-- 1 brian operators  5 Jul 11 11:18 test
-rw-r--r-- 1 brian operators  0 Jul 11 11:18 two

dir1:
total 1
-rw-r--r-- 1 brian operators 0 Jul 11 11:42 a

dir2:
total 1
-rw-r--r-- 1 brian operators 0 Jul 11 11:43 b
-rw-r--r-- 1 brian operators 0 Jul 11 11:43 c

❯ ls **/*
asdasd  best  dir1/a  dir2/b  dir2/c  one  test  two

dir1:
a

dir2:
b  c

Additional context

Related #32
Continuation of #245 (ENG-358)

Tasks

  1. Support the list -l format
  2. Files and directory's that start with . should be hidden unless -a is used.
  3. Support wild cards and globing.
  4. Support specifying multiple paths.
  5. Seamlessly support using normal and secret paths.
@aryanjassal aryanjassal added the development Standard development label Sep 10, 2024
@aryanjassal aryanjassal self-assigned this Sep 10, 2024
Copy link

linear bot commented Sep 10, 2024

@CMCDragonkai
Copy link
Member

This name isn't really good. Separate the 2 issues by scope. And name these issues by their specific scope.

@CMCDragonkai
Copy link
Member

Continuation of blah blah. Is not a good name. Please fix this and review all issue names @tegefaulkes

@tegefaulkes tegefaulkes changed the title Continuation of implementing secrets ls command Adding long list -l format and hidden file support to secrets ls command Sep 10, 2024
Copy link
Member

Note that generally we always support long options as well. And the problem is that these short options may conflict with options that PK CLI already does. Something we may need to be clear or implement in our CLI framework is positional key arguments, where -l and -a only takes effect when in the position of pk secrets ls …. Note the usage of --, which indicates further arguments are positional parameters, and should not be interpreted as options (https://stackoverflow.com/a/43047085). We may have to specalize certain options to in the position of pk [PKOPTIONS] cmd1 cmd2 [CMDOPTIONS] -- positional positional positional.

Another way is where -v has meaning if not further specialized (overridden by the command). But I dislike this shadowing of global options, it makes it unintuitive to remember where I can use -v to mean generally a verbose kind of option. Like pk -v cmd1 cmd2 -v. Does the second -v have a special meaning because of cmd2 whereas in cmd3 it may have the same meaning of -v.

So how should we solve this…?

@CMCDragonkai
Copy link
Member

So examining other commands including Git and Docker, they do have a strict placement of global options before the subcommand and local options on the subcommand.

That is:

git -v status vs git status -s
docker -D run ... vs docker run -it

So in our case, that could also be true. One example of global option is -np|--node-path, -pf|--password-file, -f|--format and -v|--verbose.

This appears to be placed in CommandPolykey:

    // Add all default options
    // these options will be available across the command hierarchy
    // the values will be captured by the root command
    this.addOption(binOptions.nodePath);
    this.addOption(binOptions.passwordFile);
    this.addOption(binOptions.format);
    this.addOption(binOptions.verbose);

One could argue that in this case, it is rare for a conflict to occur. But these options should then be able to be in the position like pk -np ... cmd1 -np or pk -v cmd1 -v.

I still like to auto-inherit the meaning of the global option, because it's just convenient to write -v at the very end of the subcommands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Standard development
Development

No branches or pull requests

2 participants