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

Make some sort of argument grepper thing #31

Open
cmcculloh opened this issue Jan 13, 2012 · 4 comments
Open

Make some sort of argument grepper thing #31

cmcculloh opened this issue Jan 13, 2012 · 4 comments
Milestone

Comments

@cmcculloh
Copy link
Owner

Make a thing that will inspect the passed in arguments for:

A) Valid argument count
B) Valid argument syntax
C) --admin flag (so it can be passed along to other scripts)

@Smolations
Copy link
Collaborator

Could you elaborate on this? And also maybe give an example of when you needed it?

@cmcculloh
Copy link
Owner Author

Make a function that will accept two things:

  1. A pattern
  2. The user specified args

So, for the "commit" command for example, you could perhaps call the function like this:

checkargs "commit string -[aA] [--admin]" $

Then the checkargs function would inspect the expected pattern against what was actually entered.

I don't like my example because I don't want the function to be complicated to call. Perhaps something like this would be better:

#simply pass in the gitscripts command that you are checkargsing for, and the checkargs function will somehow know
#the args etc for that command. In the example below we are checkargsing for the "commit" command...
checkargs "commit" "$@"

or (and I don't like this one better, but at least the pattern is parameterized):

#top of commit.sh file
expectedArgPattern="commit [a-zA-Z-_"'\ ]* [-a-A]* [--admin]*"
checkargs $expectedArgPattern "$@"

Again, these are just examples of the concept. The actual implementation could look much different, and I haven't/didn't put a whole lot of thought into this, I just know I'd like to see something like this happen...

@Smolations
Copy link
Collaborator

Hmmm...well the only issue I can think of off the top of my head is that putting the validation into a function means we won't know which arguments are which. For instance, the branch command takes a number of arguments(branch [options] [search-string]), and the order doesn't matter as each is checked for specifically. Since the order doesn't matter, putting this check in a function means we don't know which argument is the admin flag or the branch name, etc.

The only way around that would have to be exporting a variable like we do with __menu and __set_remote. However, that means that we would need to memorize each exported variable for each command we grep arguments for. Thoughts?

@cmcculloh
Copy link
Owner Author

This is more wish-list than anything. In my dreams it would look at the gsman docs for each command and then compare the user input with the expected input and respond accordingly.

@chriscorwin chriscorwin modified the milestone: Backlog Feb 26, 2016
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

3 participants