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

Ingest with shell expanded list of files throws "Error: accepts at most 1 arg(s), received x" #70

Open
lukasmalkmus opened this issue Apr 9, 2021 · 5 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@lukasmalkmus
Copy link
Collaborator

The example of the ingest command says:

# Ingest the contents of all files inside /var/logs/nginx with
# extension ".log" into a dataset named "nginx-logs":
$ axiom ingest nginx-logs -f /var/logs/nginx/*.log

But it actually throws Error: accepts at most 1 arg(s), received x, with x being the amount of actual files the shell expanded to.

@lukasmalkmus lukasmalkmus added the bug Something isn't working label Apr 9, 2021
@lukasmalkmus lukasmalkmus added this to the v0.3.0 milestone Apr 9, 2021
@lukasmalkmus lukasmalkmus self-assigned this Apr 9, 2021
@lukasmalkmus
Copy link
Collaborator Author

lukasmalkmus commented Apr 9, 2021

This is actually harder than expected because values not associated with a flag are treated as "normal" arguments. And the ingest command already takes the dataset as an argument. This could make detection of dataset arguments and file arguments tricky.

Imagine

$ axiom ingest nginx-logs -f /var/logs/nginx/*.log

which will expand to

$ axiom ingest nginx-logs -f /var/logs/nginx/access.log /var/logs/nginx/error.log

We could get away with this by treating every argument after the -f flag as an argument to that very flag. But what if users swap flag and dataset argument?

$ axiom ingest -f /var/logs/nginx/access.log /var/logs/nginx/error.log nginx-logs

This would treat the nginx-logs argument as a file and not as the dataset to ingest into.

Feel free to propose solutions or other ideas.

/cc @cdeutsch

@cdeutsch
Copy link

cdeutsch commented Apr 12, 2021

@lukasmalkmus that's weird.

What's expanding "/var/logs/nginx/*.log" to an array? The OS?

@lukasmalkmus
Copy link
Collaborator Author

lukasmalkmus commented Apr 12, 2021

This is called shell expansion and is performed by your shell (most likely bash, zsh or fish) before the command is run. It is actually not that weird. Just harder to handle for us, because we take a flag argument.

Another, simple solution would be to make the dataset a flag argument and treat non-flag arguments as files:

$ axiom ingest -d test *.json

This would work.

@cdeutsch
Copy link

Yeah, not sure what's the best experience. How do most programs handle this?

Supporting wild cards isn't critical IMO, so can possibly drop this

@lukasmalkmus
Copy link
Collaborator Author

Good question tbh. I think I'll leave this open for discussion for now. I could argue for/against both approaches. Something else that came to my mind is, that this issue can currently be worked around:

$ cat *.json | axiom ingest test

@lukasmalkmus lukasmalkmus modified the milestones: v0.4.0, v0.6.0 Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants