Skip to main content
17 votes

How are applications where any command can be run CLI, but also has a UI element, structured?

I noticed that any manipulation of GUI elements automatically generates a command that shows up in the CLI, which implies that GUI inputs (for example textboxes) are not binded to some underlying data,...
Flater's user avatar
  • 59.5k
7 votes
Accepted

Parsing complex object-like parameters via CLI arguments

CLI programs often resort to file or stdin based input when data is more complex than can be properly communicated via command line. For example, GNU grep allows multiple patterns on the command line, ...
Hans-Martin Mosner's user avatar
7 votes
Accepted

Is there a canonical way to format 'usage' output for a cli script?

In the Python world, by far the most common is "do what argparse does". The reasons for this are hopefully obvious.
Philip Kendall's user avatar
7 votes
Accepted

Adding a CLI to a Windows service

This is a classic separation of concerns. You have one use-case for a process that runs as a headless Windows service performing tasks. You have a second use case for a CLI tool parsing command line ...
Avner Shahar-Kashtan's user avatar
6 votes

How are applications where any command can be run CLI, but also has a UI element, structured?

I would argue that this is not what is commonly called CLI, but a Console in an already running GUI that provides CLI. Console is typically openable from within the GUI and allows to issue commands to ...
Kromster's user avatar
  • 607
6 votes
Accepted

Multi-level validation in C#

Here is my solution. It is not perfect, but it is a start. First of all, I have created an enum called ErrorLevel: enum ErrorLevel { Error, Warning } Next, for every validation rule, I have ...
Michael Haddad's user avatar
5 votes

Choosing the right paradigm when building a GUI for an application

I've seen a program from a vendor shipped with two UIs, i.e. as a GUI and as a console program. They're implemented as two EXEs calling a common DLL. And by using the DLL's API (ignoring both of the ...
ChrisW's user avatar
  • 3,427
5 votes
Accepted

Put functionality in same executable with command-line flag, or put it in a separate executable?

Don't go with separate executables if it means duplicating stuff that now has to be kept in sync. If anything create different "front ends" to access it. I've solved exactly this problem by offering ...
candied_orange's user avatar
5 votes

Adding a CLI to a Windows service

What you're describing sounds an awful lot like most DBMSes. For example, the MySQL Service process, mysqld, runs independently and does all the heavy lifting. It's Command Line Interface, mysql, ...
Phill  W.'s user avatar
  • 13.1k
5 votes
Accepted

Why have a path argument when there is cwd

The authors of a command line utility do not have control over the execution environment, or how the utility is invoked. You, as the command line user, might know that the current working directory is ...
Greg Burghardt's user avatar
5 votes
Accepted

Problems with designing an intuitive cli experience

For your design goals of the system being modular, intuitive and fault-resistant you should avoid any temporal coupling between the sub-commands (temporal coupling = you need to run command A before ...
Bart van Ingen Schenau's user avatar
5 votes
Accepted

The applicability of functional core - imperative shell to a cli program which contains a wrapper around a binary

FCIS is a helpful approach when you have a reasonable amount of processing logic which can be implemented in a purely functional manner. This logic can be moved to the "functional core". On ...
Doc Brown's user avatar
  • 220k
4 votes

How are applications where any command can be run CLI, but also has a UI element, structured?

Proper separation of concerns takes care of it all. Rather than handling all the stuff that that button press needs to accomplish in the event handler for the button, have the event handler just do ...
jwenting's user avatar
  • 10.1k
4 votes
Accepted

How does a site API determine the difference between a user and program request in a browser?

In general, websites look for anomalous traffic patterns. Cookies that don't match up, requests made in the wrong order, that sort of thing. If a website is keenly interested in this distinction, ...
Robert Harvey's user avatar
4 votes
Accepted

Grouping non-boolean command-line options

It's quite common to add a non-boolean option at the end of a group of boolean options, like: git commit -am "My commit message" Otherwise, your assessment is spot on.
Karl Bielefeldt's user avatar
3 votes

How to write documentation for CLI app that requires stdin?

Requiring stdin is a bit limiting. A common practice is to let the user specify a file that the application will read. Example: gzip -c /tmp/file1 pv /tmp/file1 sha1sum /tmp/file1 Now, if the user ...
Arseni Mourzenko's user avatar
3 votes

Choosing the right paradigm when building a GUI for an application

In my experience it is unusual, but not unheard of for a gui to invoke a cli. ie button presses on a graphical interface to launch a command line behind the scenes. The main argument against it is ...
Ewan's user avatar
  • 84.4k
2 votes

Server-client CLI messaging design

You compare very different kind of communication protocols: POSIX Sockets are available on all TCP/IP enabled platforms (e.g. linux, windows) and not only unix. It's a flexible communication ...
Christophe's user avatar
  • 82.2k
2 votes

How should I manage user session in CLI application?

I found an answer here: https://stackoverflow.com/questions/9146217/how-does-heroku-store-its-authentication-on-its-command-line-app It has a Heroku's site link and explains very well how they face ...
Héctor Valls's user avatar
2 votes

Is MVC an architectural pattern for user-interactive applications only?

If you see in wiki, they said, Model–View–Controller is a software design pattern commonly used for developing user interfaces which divides the related program logic into three interconnected ...
Sazzad Hissain Khan's user avatar
2 votes

Is there a canonical way to format 'usage' output for a cli script?

There is a GNU Standard which is slightly more than to follow the POSIX Standard, which is used by a great number of programs and a good template to follow. There is a style for Windows, but it is ...
whatsisname's user avatar
  • 27.7k
2 votes
Accepted

Dynamic loading of objects defined during development for a running system

The general name for your search terms is a "plugin architecture" supporting "hot reload". You may be surprised to lean that it's not specific to interpreted languages. You can do ...
pjc50's user avatar
  • 15.3k
2 votes

How are applications where any command can be run CLI, but also has a UI element, structured?

If you have a "model-view-controller" internal structure, and especially if you use the "command pattern" internally, then the command line becomes just another form of View. This ...
pjc50's user avatar
  • 15.3k
2 votes

How are applications where any command can be run CLI, but also has a UI element, structured?

Applications like this use in general some variant of the command pattern as core way to operate on the model. The GUI operations generate internal commands, and CLI commands are just a way to ...
Christophe's user avatar
  • 82.2k
1 vote
Accepted

Is it better practice to set default values for optional argparse arguments?

The premise behind your question is mistaken. >>> import argparse >>> p = argparse.ArgumentParser() >>> p.add_argument('-a') >>> p.parse_args() Namespace(a=None) ...
chepner's user avatar
  • 183
1 vote

Dynamic loading of objects defined during development for a running system

It is not clear what you have tried and what your actual problem is. In Python, you can just exec() a string, which may have been read from a file. This may contain anything, including class ...
Hans-Martin Mosner's user avatar
1 vote
Accepted

Event loop for console input

Quite often server processes are run truly headless: input and output redirected to null. Re-using the application's standard input means that only one user can access it, and that must be the user ...
pjc50's user avatar
  • 15.3k
1 vote

How to write documentation for CLI app that requires stdin?

After looking at manpages for wc and grep I've come to conclusion that there is no standardized way of documenting if program allows for reading via standard input. The most common pattern, if the ...
user3056783's user avatar
1 vote

How to launch a detached child process in Node, and reuse it on subsequent executions if already running?

The way to do this would be to use a file lock in your background program to check if it's already running. Here is a library that uses file locks to implement something called a named mutex. To make ...
Blake's user avatar
  • 391
1 vote
Accepted

CLI and Lib package, where to put module loading code

Suppose you are also creating a REST API and/or a GUI for your system. Would the logic for loading plugins be different than for your current CLI? If not, then the plugin loading logic belongs in the ...
Bart van Ingen Schenau's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible