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

Can't add a new type, keep getting ''Invalid arguments". #15

Closed
smaximov opened this issue Sep 23, 2016 · 12 comments
Closed

Can't add a new type, keep getting ''Invalid arguments". #15

smaximov opened this issue Sep 23, 2016 · 12 comments
Labels
bug A bug.

Comments

@smaximov
Copy link

smaximov commented Sep 23, 2016

Trying to add a new type results in the "Invalid arguments." error followed by the usage message.

I have tried the example from README (rg --type-add 'foo:*.foo,*.foobar') and some other patterns.

My environment:

  • Fedora 24 (x86_64).
  • Rust (tried both):
    • rustc 1.13.0-nightly (4f9812a59 2016-09-21)
    • rustc 1.11.0 (9b21dcd6a 2016-08-15)
  • ripgrep: 0.1.16
@BurntSushi
Copy link
Owner

Could you show precisely the command you're running and the full output?

I wonder if I messed up the docs. It looks like comma separated globs aren't supported, but they probably should be.

Using --type-add for each glob should do as a workaround for now. (You the globs are additive, so you can have multiple --type-add flags for the same type.)

@BurntSushi BurntSushi added the bug A bug. label Sep 23, 2016
@smaximov
Copy link
Author

I have just built ripgrep using the stable rust (rg was bumped to 0.1.17) with no effect.

Could you show precisely the command you're running and the full output?

Sure:

$ rustup show                       
Default host: x86_64-unknown-linux-gnu

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.11.0 (9b21dcd6a 2016-08-15)
$ rg --version
0.1.17
$ rg --type-add 'foo:*.foo,*.foobar'
Invalid arguments.

Usage: rg [options] -e PATTERN ... [<path> ...]
       rg [options] <pattern> [<path> ...]
       rg [options] --files [<path> ...]
       rg [options] --type-list
       rg --help
       rg --version
$ rg --type-add 'foo:*.foo'         
Invalid arguments.

Usage: rg [options] -e PATTERN ... [<path> ...]
       rg [options] <pattern> [<path> ...]
       rg [options] --files [<path> ...]
       rg [options] --type-list
       rg --help
       rg --version

I use ZSH, but I've also tried bash to make sure it's not a shell issue.

@smaximov
Copy link
Author

smaximov commented Sep 23, 2016

Using --type-add for each glob should do as a workaround for now.

Does adding a single glob at a time work for you? If it does, I'll try to debug this issue tomorrow with my setup.

@BurntSushi
Copy link
Owner

BurntSushi commented Sep 23, 2016

Running rg --type-add 'foo:*.foo' is indeed invalid. You need to actually provide a pattern to search. :-)

@hodavidhara
Copy link

I haven't been able to add a type either. Tried a bunch of stuff:

$ rg --type-add 'ts:*.ts,*.tsx'
Invalid arguments.
$ rg --type-add 'ts:*.ts'
Invalid arguments.
$ rg --type-add ts *.ts
invalid definition (format is type:glob, e.g., html:*.html)
$ rg --type-add ts:*.ts
Invalid arguments.

I'm on os X el capitan (10.11.6) and Installed it with the homebrew command in the readme.

@BurntSushi
Copy link
Owner

You need to provide a pattern to search. Ripgrep doesn't save any state or config anywhere. --type-add only applies to the current command.

@hodavidhara
Copy link

Ahh, I guess I misunderstood from the documentation. I thought it would add it to the list of types returned by rg --type-list to be used with -t and -T in the future. So if I understand correctly rg --type-add 'ts:*.ts' -tts foo would be the same as rg foo -g *.ts?

@BurntSushi
Copy link
Owner

@hodavidhara That sounds right yes! I'll work on improving the docs. :-)

@smaximov
Copy link
Author

Ripgrep doesn't save any state or config anywhere. --type-add only applies to the current command.

I indeed expected --type-add to persist the new type to some sort of config , not to be just a modifier for the search (though it would be more useful that way, IMHO). Thanks for the clarification!

@BurntSushi
Copy link
Owner

My kinda-sorta intention is to see how far we can get with configuring "default" options just by using aliases. So for example, alias rg="--type-add 'foo:*.foo'". I agree that this can get a bit unwieldy if you have a lot of custom types, but I also kind of expect to be pretty lenient with putting types into rg itself (ya know, good defaults and all).

@smaximov
Copy link
Author

My kinda-sorta intention is to see how far we can get with configuring "default" options just by using aliases. So for example, alias rg="--type-add 'foo:*.foo'"

Yes, that use-case makes sense, I haven't thought about it before.

@cldwalker
Copy link

I also was confused and assumed custom types persisted. Seeing --type-add, --type-clear and --type-list, I assumed add persisted since there was a clear operation

amsharma91 added a commit to amsharma91/ripgrep that referenced this issue Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug.
Projects
None yet
Development

No branches or pull requests

4 participants