Config file or parameters, plus parameter standards

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
0x2620

Config file or parameters, plus parameter standards

Post by 0x2620 »

I'm writing a Java program to print pointer tables, and the parameters keep piling up. What's the cut-off point for too many parameters - when do you move them all to a config file?

Also is there a *nix standard (or best practices) anywhere for formatting parameters for CLI apps?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29509
Joined: Wed Jul 06, 2011 3:58 am

Re: Config file or parameters, plus parameter standards

Post by xenopeek »

0x2620 wrote:What's the cut-off point for too many parameters - when do you move them all to a config file?
There's not really a cut-off point. There are plenty of CLI programs that have more parameters then you can dream up. Like curl for example (the manpage online https://curl.haxx.se/docs/manpage.html).

Probably better to approach this the other way round: which parameters would a user set once and use unchanged each time they run the program, and which parameters are users likely to need/want to set to something specific each time they run the program? Consider the use of your parameters. If you do go with a config file a nice parameter to add is to use a different from default config file. So users can easily have two or more config files for particular uses.
0x2620 wrote:Also is there a *nix standard (or best practices) anywhere for formatting parameters for CLI apps?
Not really. For single letter (short) parameters use single dash. For longer than single letter (long) parameters use double dashes. Single letter parameters without (optional) arguments one would expect to be able to combine. Like if you have a -l (list) and -v (verbose) parameter, -lv should do both. Long parameters for these would for example be --list and --verbose. Good idea to have -h / --help both to show a summary of command line arguments.
Image
Locked

Return to “Scripts & Bash”