erdtree icon indicating copy to clipboard operation
erdtree copied to clipboard

Required argument `--pattern` not found even when given

Open Kushagra-0801 opened this issue 2 years ago • 3 comments
trafficstars

I wanted to used erd as an ls replacement. Since ls allows globbing without flags, I thought to make an alias for erd with the -p already present.

I made it like this:

In config file:

[ls]
human = true
disk-usage = "logical"
long = true
level = 1
suppress-size = true
layout = "inverted"

[lsf]
human = true
disk-usage = "logical"
long = true
level = 1
suppress-size = true
layout = "inverted"
glob = true

and then the aliases:

alias ls='erd --config ls'
alias lsf='erd --config lsf --pattern'

And I tried to use it like

lsf '*'

I get the following error:

error: the following required arguments were not provided:
  --pattern <PATTERN>

Usage: -- --pattern <PATTERN> --suppress-size --glob --human --level <NUM> --disk-usage <DISK_USAGE> --long --layout <LAYOUT> [DIR]

For more information, try '--help'.

If I run

lsf --pattern '*'

I get the following error:

error: a value is required for '--pattern <PATTERN>' but none was supplied

For more information, try '--help'.

But if I run

ls --glob --pattern '*'

then it works.


Beyond this main issue, I have some other minor requests / questions as well.

  1. How can I have globbing work for both files and directories at the same time?
  2. Is there some way I can pass the pattern without quoting it? Basically, letting the shell do the globbing and have erd work like ls with arguments given.

Kushagra-0801 avatar Aug 23 '23 05:08 Kushagra-0801

That is a bug. I'll work on getting that fixed ASAP. As for your questions:

  1. Globbing for different file-types in one query isn't supported, but I'll work on getting that supported for the next release.
  2. Could you provide an example for this use-case? I don't see how this would work given that erd expects only a single positional argument which is the directory to traverse, but perhaps it'll make sense once I see what you're trying to accomplish.

solidiquis avatar Aug 24 '23 06:08 solidiquis

Could you provide an example for this use-case? I don't see how this would work given that erd expects only a single positional argument which is the directory to traverse, but perhaps it'll make sense once I see what you're trying to accomplish.

With log files or static assets or in just a lot of cases, it happen that I have a couple hundred files in a directory. With ls I would do ls *-2023-08-* to list out all log files in august. I can do this with erd as well but it requires quoting. erd --glob --pattern '*-2023-08-*'. Even without the globs, sometimes I want to check whether a file just exists or not so running ls with the filename is what I do. Doing the same with erd fails with either can't compute root node or too many arguments.

It's not a huge problem to be honest, but old habits die hard.

Kushagra-0801 avatar Aug 24 '23 07:08 Kushagra-0801

ahhh okay that makes sense. Ignore what I said earlier about it not being possible, I didn't correctly envision what you were asking for. It should definitely be possible. I'll add that into my list of todos to include in the next release.

solidiquis avatar Aug 24 '23 07:08 solidiquis