Principles of command line program design ========================================= 1. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119. 2. All program command-line options SHOULD be optional. 3. A program SHOULD read one or more input files specified on the command line. If no input files are specified the program SHOULD read from STDIN. If a file name is '-' (a single hyphen), the program SHOULD read from STDIN instead of file named "-". File name, whenever it is reported in the output, SHOULD be reported as "-" when reading from STDIN. 4. When reading from STDIN and STDIN is a TTY, the program SHOULD output to STDERR a NOTE level message indicating that it is reading from STDIN. 5. The program SHOULD NOT modify its input files, unless explicitly requested (options '--in-place', '--output', etc.) 6. If the program output is text, and can be presented as a text stream, the program SHOULD output its results to STDOUT. 7. If the program output is binary, it should be output to a file that has a name bases on the program's name and possibly the input file name and/or the file creation date. 8. If the program, due to its function, has to produce multiple output files, it SHOULD output files under generated names in the current working directory. 9. When a program writes to a file with a "synthesised" file name (i.e. the file name that was not provided by the user on the command line), the program SHOULD output a NOTE level messages to STDERR reporting the output file name. 10. If the program creates multiple files in the file system, there MUST be a way to specify its output directory (for instance, as an argument for the '--outdir' option, or as the last argument of the program). 11. Whenever the program writes outputs to a file or to multiple files, there SHOULD be an option to redirect those files, either a selected one, or several of them (even all of them) to STDOUT (e.g. using the '--stdout' option); 12. The program MAY concatenate multiple output file data when sending its results to STDOUT; there SHOULD be means to identify individual file boundaries in the STDOUT output stream. 13. If the program writes multiple data items (files) to STDOUT, and the data stream does not allow to identify file boundaries unambiguously, the program MAY use additional wrappers for these data items (e.g. warp them into XML elements, ZIP, TAR or similar files, insert program-specific separators that can unambiguously separated from the data, or similar). 14. If a program uses program-specific separators to separate individual file data in the STDOUT, these separators and the way to recover individual file data MUST be documented in the program specification and in the 'man' or '--help' messages. 15. Program specification MUST include: -- a short description of programs functions. Invariants that are true after the successful execution of the program SHOULD be specified or SHOULD be easily derivable; -- specification of input file formats; -- specification of output file formats; -- the input and output file formats MUST either be described unambiguously by a formal computer-readable means (e.g. by providing grammars, XML or JSON schemas, regular expressions), or MUST refer (with full bibliography and URI) to an existing format description. 16. Program specification SHOULD include program call name; 17. Program specification SHOULD include the list of options that the program must supports. 18. Information about program options, inputs, outputs and their formats SHOULD be included in the program documentation ('man' and/or '--help' messages). References ========== [1] S. Bradner "Key words for use in RFCs to Indicate Requirement Levels", RFC 2119, URI: https://tools.ietf.org/html/rfc2119