I'm interested to read more about this topic.
I maintain about 8-10 Python Click CLI scripts (a la 'Practical Business Python') which are basically clones of 2-3 original scripts. These have worked really well for me (developing them) and for the handful of colleagues who I share them with.
This summer I started a project to put a Flask front end on a few of the CLI scripts.
Reading the OP I started to imagine the decorator-on-function from `typer` might be an interesting way to maintain functions for the Flask App to call and still preserve the CLI functionality.
Then again, and I'm a neophyte here, I assume a 'library' formalization would give me both options as well...
that was the main point.
> should report back logic faults from within the library
And I suggest validating parameters passed to functions.
So what's this you disagree with?
1) CLI support is an additional logic in your program that makes no real work
CLI is a user interface, it does real work as giving user way to interact with your program. It's an interface.
2) Error (exception) handling with CLI is very poor. Another layer of (bad faulty) code is required to make it possible.
Like with any other code. That's why you should to test it (like any other code).
3) Scaling/extending is not as easy compared to programming language APIs (see example in the end)
It's much easier. At least to my wife, who isn't programmer, but can use shell.
4) CLIs are detached from essential code, which in most cases is disadvantage.
What cases?
5) Forcing users to use CLI means: stay away from my code, you’d better not work with it.
Why having CLI would have to force the user to not use the library (if it is intended to be a library, not a stupid tool)
To sum up:
API != User Interface. API = Programming Interface.
Two different goals, two different sets of requirements. You can't just reduce one to another.
That's where we should start, but the other way around. Why do you keep trying to replace programming interfaces with bash calls?
Any example when calling cli compared to proposed alternative makes any difference to your spouse?
User != Programmer
Also, "bash calls" are cool - shell is a great tool to compose many diverse tools written in different programming languages. If all the tools were just configurable via writing code in their implementation language: 1) you would have to know all the programming languages 2) you would have to somehow input the code, parameters are just shorter than code
Any system worth keeping around should be a library (or family of libraries) which have a CLI fronting it that serves to pass parameters to it just as you might any other way (such as through some other program or REST API or GUI). Agree the CLI "shell" around the system should not have separate logic, but should report back logic faults from within the library.