Open lsjroberts opened 5 years ago
Another alternative for args and flags would be:
export default command({
args: {
entry: required(),
},
flags: {
clean: [alias('c'), boolean(false)],
outDir: [alias('o'), string('./dist')],
},
});
Defaults could be shortcut with:
flags: {
clean: false,
outDir: './dist',
},
How would terminal apps call other terminal apps, without requiring spawn
permissions?
import say from 'hello/say';
export default Terminal.action(async () => {
await say('Hello, World!');
});
(Since permissions are inherited from dependencies an app that imports the above app would also require approval for hello/say
's permissions).
And flags might be:
say('Hello', { colors: true })
Positional arguments occur before flags.
Would that cause issues with object args?
At the root of Wool's philosophy are three concepts:
To that end, the
wool/terminal
package will provide a way to create command line applications from simple single commands to git-style programs with sub-commands and curses / blessed style views.All applications, be they cli or web-based, will be expected to export a default entry. This is much the same as a
main
function in many common languages such as C and Python.Programs
All these programs would automatically support
--help
and--version
, e.g.:And as per #1 they would require the user to give them permission before being able to perform dangerous actions such as calling functions from
wool/fs
and similar.Action
A single action that takes no input from the outside world.
Command
A command that can be given arguments and flags.
Application
An application that can call off to many commands.
UI Program
A curses / blessed style view.
Questions
Command argument and flag syntax
Above, I've used a variable args syntax:
A strictly FP approach would look like:
But this is clearly a bit rubbish.
Another alternative would be chained functions, e.g.: