|Think about Loose Coupling|
Why is it good practice for a cli script to take switch args before file list?by leocharre (Priest)
|on Jul 19, 2006 at 15:16 UTC||Need Help??|
leocharre has asked for the wisdom of the Perl Monks concerning the following question:
I have a cli script that takes as arguments a file path, and optionally, some switches. I am using Getopt::Std right now.
I was having some trouble with the interface. I wanted the user to have to specify switches (-f-a -w hatever) - but I wanted the script to catch any ARGV that does not have a switch and take it as a file argument..
I wanted the following to be valid ways to call the script:
script ./thisfile -f -a
Getopt::Std allows me to do this.. but if I specify the arguments first, then the file arguments
This is where I get the options..
Upon further reading, I see that it is widely recomended (for example in Getopt:Long ) that one provide switch arguments first, and then a file list..
I think in the case of this script I'm working on.. It may be more convenient to specify path first. The script is an interface to showing and editing metadata on a file or directory .. here are some usage examples:
the constant is that they provide filepath(s).. so I feel silly asking them to turn the above examples to..