Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Q&A For scripting what are the pros and cons of command line arguments versus capturing input at the start?

I would like to add further options to the set of possibilities, namely environment variables and GUI input. Moreover, I would like to distinguish reading information from stdin and from other (na...

posted 10mo ago by Dirk Herrmann‭  ·  edited 10mo ago by Dirk Herrmann‭

Answer
#3: Post edited by user avatar Dirk Herrmann‭ · 2023-06-23T21:40:50Z (10 months ago)
  • I would like to add further options to the set of possibilities, namely _environment variables_ and _GUI input_. Moreover, I would like to distinguish reading information from `stdin` and from other (named) files, as this has some architectural implication.
  • With the options from the OP and other answers taken into account, this gives the following set of possibilities how configuration input can be provided to an executable:
  • * Command line arguments
  • * Environment variables
  • * Non-interactive input via `stdin` (typed in or via file re-direction)
  • * Input file (opened by name)
  • * Interactive input via `stdin`
  • * Interactive input via GUI
  • All of these options have their justifications depending on the circumstances, and it can even make sense to combine some of them - for example providing the name of some configuration file via command line or in an environment variable.
  • Among the decision criteria - some of them have been mentioned by others - are the following (and for different use cases your answers and the resulting tradeoff will be different):
  • * What is your user base? Do they need guidance while providing the data? Shall they be able to correct mistakes during entering the data? If this is the case, some interactive form of input is preferable.
  • * How complex is the data that needs to be provided? Is it simple numbers or nested, possibly even recursive data structures? The more complex, the less suited are command line arguments, environment variables and interactive console input.
  • * How much data has to be provided? For large data, command line and environment variables can not be used, as there are system limits on their sizes.
  • * How many individual data items have to be provided? It is not advisable to have lots of environment variables, due to the system limits but also due to the increasing risk of name clashes.
  • * Is the possibility to automate your program relevant? GUI input is hard to automate, interactive console I/O is easier, but non-interactive forms are easiest.
  • * Is it desirable to have several levels of configuration, like, system configuration in a file like /etc/<system-cfg>, user configuration in ~/.<user-cfg>, shell session configuration in environment variable, process configuration on command line, final changes made interactively?
  • * Is your configuration meant to address your program as a whole, or maybe just some library you use? With environment variables and configuration files you can provide data directly to libraries (bypassing the main program), If you provide data via command line or via stdin, the main program is always involved and has to forward the data to the library (this is the architectural relevance of stdin mentioned above).
  • I would like to add further options to the set of possibilities, namely _environment variables_ and _GUI input_. Moreover, I would like to distinguish reading information from `stdin` and from other (named) files, as this has some architectural implication.
  • With the options from the OP and other answers taken into account, this gives the following set of possibilities how configuration input can be provided to an executable:
  • * Command line arguments
  • * Environment variables
  • * Non-interactive input via `stdin` (typed in or via file re-direction)
  • * Input file (opened by name)
  • * Interactive input via `stdin`
  • * Interactive input via GUI
  • All of these options have their justifications depending on the circumstances, and it can even make sense to combine some of them - for example providing the name of some configuration file via command line or in an environment variable.
  • Among the decision criteria - some of them have been mentioned by others - are the following (and for different use cases your answers and the resulting tradeoff will be different):
  • * What is your user base? Do they need guidance while providing the data? Shall they be able to correct mistakes during entering the data? If this is the case, some interactive form of input is preferable.
  • * How complex is the data that needs to be provided? Is it simple numbers or nested, possibly even recursive data structures? The more complex, the less suited are command line arguments, environment variables and interactive console input.
  • * How much data has to be provided? For large data, command line and environment variables can not be used, as there are system limits on their sizes.
  • * How many individual data items have to be provided? It is not advisable to have lots of environment variables, due to the system limits but also due to the increasing risk of name clashes.
  • * Is the possibility to automate your program relevant? GUI input is hard to automate, interactive console I/O is easier, but non-interactive forms are easiest.
  • * Is it desirable to have several levels of configuration, like, system configuration in a file like `/etc/<system-cfg>`, user configuration in `~/.<user-cfg>`, shell session configuration in environment variable, process configuration on command line, final changes made interactively?
  • * Is your configuration meant to address your program as a whole, or maybe just some library you use? With environment variables and configuration files you can provide data directly to libraries (bypassing the `main` program), If you provide data via command line or via `stdin`, the `main` program is always involved and has to forward the data to the library (this is the architectural relevance of `stdin` mentioned above).
#2: Post edited by user avatar Dirk Herrmann‭ · 2023-06-23T21:38:25Z (10 months ago)
  • I would like to add further options to the set of possibilities, namely _environment variables_ and _GUI input_. Moreover, I would like to distinguish reading information from `stdin` and from other (named) files, as this has some architectural implication.
  • With the options from the OP and other answers taken into account, this gives the following set of possibilities how configuration input can be provided to an executable:
  • * Command line arguments
  • * Environment variables
  • * Non-interactive input via `stdin` (typed in or via file re-direction)
  • * Input file (opened by name)
  • * Interactive input via `stdin`
  • * Interactive input via GUI
  • All of these options have their justifications depending on the circumstances, and it can even make sense to combine some of them - for example providing the name of some configuration file via command line or in an environment variable.
  • Among the decision criteria - some of them have been mentioned by others - are the following (and for different use cases your answers and the resulting tradeoff will be different):
  • * What is your user base, are they interested and likely capable to automate their use of your program? Do they need guidance while providing the data? Shall they be able to correct mistakes during entering the data? If this is the case, some interactive form of input is preferable.
  • * How complex is the data that needs to be provided? Is it simple numbers or nested, possibly even recursive data structures? The more complex, the less suited are command line arguments, environment variables and interactive console input.
  • * How much data has to be provided? For large data, command line and environment variables can not be used, as there are system limits on their sizes.
  • * How many individual data items have to be provided? It is not advisable to have lots of environment variables, due to the system limits but also due to the increasing risk of name clashes.
  • * Is the possibility to automate your program relevant? GUI input is hard to automate, interactive console I/O is easier, but non-interactive forms are easiest.
  • * Is it desirable to have several levels of configuration, like, system configuration in a file like /etc/<system-cfg>, user configuration in ~/.<user-cfg>, shell session configuration in environment variable, process configuration on command line, final changes made interactively?
  • * Is your configuration meant to address your program as a whole, or maybe just some library you use? With environment variables and configuration files you can provide data directly to libraries (bypassing the main program), If you provide data via command line or via stdin, the main program is always involved and has to forward the data to the library (this is the architectural relevance of stdin mentioned above).
  • I would like to add further options to the set of possibilities, namely _environment variables_ and _GUI input_. Moreover, I would like to distinguish reading information from `stdin` and from other (named) files, as this has some architectural implication.
  • With the options from the OP and other answers taken into account, this gives the following set of possibilities how configuration input can be provided to an executable:
  • * Command line arguments
  • * Environment variables
  • * Non-interactive input via `stdin` (typed in or via file re-direction)
  • * Input file (opened by name)
  • * Interactive input via `stdin`
  • * Interactive input via GUI
  • All of these options have their justifications depending on the circumstances, and it can even make sense to combine some of them - for example providing the name of some configuration file via command line or in an environment variable.
  • Among the decision criteria - some of them have been mentioned by others - are the following (and for different use cases your answers and the resulting tradeoff will be different):
  • * What is your user base? Do they need guidance while providing the data? Shall they be able to correct mistakes during entering the data? If this is the case, some interactive form of input is preferable.
  • * How complex is the data that needs to be provided? Is it simple numbers or nested, possibly even recursive data structures? The more complex, the less suited are command line arguments, environment variables and interactive console input.
  • * How much data has to be provided? For large data, command line and environment variables can not be used, as there are system limits on their sizes.
  • * How many individual data items have to be provided? It is not advisable to have lots of environment variables, due to the system limits but also due to the increasing risk of name clashes.
  • * Is the possibility to automate your program relevant? GUI input is hard to automate, interactive console I/O is easier, but non-interactive forms are easiest.
  • * Is it desirable to have several levels of configuration, like, system configuration in a file like /etc/<system-cfg>, user configuration in ~/.<user-cfg>, shell session configuration in environment variable, process configuration on command line, final changes made interactively?
  • * Is your configuration meant to address your program as a whole, or maybe just some library you use? With environment variables and configuration files you can provide data directly to libraries (bypassing the main program), If you provide data via command line or via stdin, the main program is always involved and has to forward the data to the library (this is the architectural relevance of stdin mentioned above).
#1: Initial revision by user avatar Dirk Herrmann‭ · 2023-06-23T21:37:01Z (10 months ago)
I would like to add further options to the set of possibilities, namely _environment variables_ and _GUI input_.  Moreover, I would like to distinguish reading information from `stdin` and from other (named) files, as this has some architectural implication.

With the options from the OP and other answers taken into account, this gives the following set of possibilities how configuration input can be provided to an executable:

* Command line arguments
* Environment variables
* Non-interactive input via `stdin` (typed in or via file re-direction)
* Input file (opened by name)
* Interactive input via `stdin`
* Interactive input via GUI

All of these options have their justifications depending on the circumstances, and it can even make sense to combine some of them - for example providing the name of some configuration file via command line or in an environment variable.

Among the decision criteria - some of them have been mentioned by others - are the following (and for different use cases your answers and the resulting tradeoff will be different):

* What is your user base, are they interested and likely capable to automate their use of your program?  Do they need guidance while providing the data?  Shall they be able to correct mistakes during entering the data?  If this is the case, some interactive form of input is preferable.
* How complex is the data that needs to be provided?  Is it simple numbers or nested, possibly even recursive data structures?  The more complex, the less suited are command line arguments, environment variables and interactive console input.
* How much data has to be provided?  For large data, command line and environment variables can not be used, as there are system limits on their sizes.
* How many individual data items have to be provided?  It is not advisable to have lots of environment variables, due to the system limits but also due to the increasing risk of name clashes.
* Is the possibility to automate your program relevant?  GUI input is hard to automate, interactive console I/O is easier, but non-interactive forms are easiest.
* Is it desirable to have several levels of configuration, like, system configuration in a file like /etc/<system-cfg>, user configuration in ~/.<user-cfg>, shell session configuration in environment variable, process configuration on command line, final changes made interactively?
* Is your configuration meant to address your program as a whole, or maybe just some library you use?  With environment variables and configuration files you can provide data directly to libraries (bypassing the main program),  If you provide data via command line or via stdin, the main program is always involved and has to forward the data to the library (this is the architectural relevance of stdin mentioned above).