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

Command with optional parameters #10

Closed
VictorKuenstler opened this issue Jul 12, 2021 · 3 comments
Closed

Command with optional parameters #10

VictorKuenstler opened this issue Jul 12, 2021 · 3 comments

Comments

@VictorKuenstler
Copy link
Contributor

Currently a command is a string. But it should be a union of string and an object. So, we should make this a struct with optional arguments.

Proposal:

struct HoardCommandd {
command: String,
args: Vec<Arg>
}

struct Arg {
name: String,
value: Optional<String>
}

So if you run a command with args with no default value, there should spawn an interactive shell.

@Hyde46
Copy link
Owner

Hyde46 commented Jul 12, 2021

Say we want to save
docker build -f ./docker/Dockerfile
This we would save just as
HoardCommand{ command: 'docker build -f ./docker/Dockerfile', args: Vec::empty() }

Alternatively, args come into play, if we want to parameterize the saved command

docker build -f ${arg1}
Which is saved as

HoardCommand{ command: 'docker build -f${arg1}', args: vec!["arg1"] }

I think we confused the Command Structure for what we parsed from the cli with what we want to save a little bit

@Hyde46
Copy link
Owner

Hyde46 commented Jul 12, 2021

Or are you proposing to save all arguments of a command as an Arg independant to whether we want it parameterized or not?

@Hyde46
Copy link
Owner

Hyde46 commented Jul 12, 2021

Also I don't think its feasible or even possible to parse all possible commands a user can enter correctly for what their arguments are, and how they are structured now that I think about it.
There are no strict conventions for that

@Hyde46 Hyde46 closed this as completed Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants