|
2 | 2 |
|
3 | 3 | This library helps you create professional command-line tools for Node.js. By "professional", we mean: |
4 | 4 |
|
5 | | -- **no gotchas for users**: Seems obvious, but try typing "`npm install --save-dex`" instead of "`npm install --save-dev`" sometime. The command seems to execute successfully, but it doesn't save anything, because the misspelled flag was silently ignored. This lack of rigor plagues many familiar NodeJS tools, and can sometimes be very confusing and frustrating! For a great user experience, a command line parser should always strictly validate all arguments. |
| 5 | +- **no gotchas for users**: Seems obvious, but try typing "`npm install --save-dex`" instead of "`npm install --save-dev`" sometime. The command seems to execute successfully, but it doesn't save anything! The misspelled flag was silently ignored. This lack of rigor plagues many familiar NodeJS tools and can be confusing and frustrating. For a great user experience, a command line tool should always be strict about its syntax. |
6 | 6 |
|
7 | | -- **no gotchas for developers**: Many command-line libraries store their parsed data in a simple JavaScript hash object. This is convenient for small projects, but suppose a large project has many different source files that define and read parameters. If you try to read `data['output-dir']` when it wasn't defined, or if you misspell the key name, your tool will silently behave as if the parameter was omitted. And is `data['max-count']` a string or a number? Hard to tell! The **ts-command-line** library models each parameter type as a real TypeScript class. |
| 7 | +- **no gotchas for developers**: Many command-line libraries store their parsed data in a simple JavaScript hash object. This is convenient for small projects. But suppose a large project has many different source files that define and read parameters. If you try to read `data['output-dir']` when it wasn't defined, or if you misspell the key name, your tool will silently behave as if the parameter was omitted. And is `data['max-count']` a string or a number? Hard to tell! We solve this by modeling each parameter kind as a real TypeScript class. |
8 | 8 |
|
9 | | -- **automatic documentation**: Some command-line libraries treat the `--help` docs as a separate exercise for the reader. **ts-command-line** requires each every parameter to have a documentation string, and will automatically generates the `--help` for you. If you want to write long paragraphs, no problem -- they will be word-wrapped correctly. *[golf clap]* |
| 9 | +- **automatic documentation**: Some command-line libraries treat the `--help` docs as someone else's job. **ts-command-line** requires each every parameter to have a documentation string, and will automatically generate the `--help` docs for you. If you like to write long paragraphs, no problem -- they will be word-wrapped correctly. *[golf clap]* |
10 | 10 |
|
11 | | -- **structure and extensibility**: Instead of a simple function chain, **ts-command-line** provides a "scaffold" pattern that makes it easy to find and understand the command-line implementation for any tool project. The scaffold model is generally recommended, but there's also a "dynamic" model if you need it. (See below.) |
| 11 | +- **structure and extensibility**: Instead of a simple function chain, **ts-command-line** provides a "scaffold" pattern that makes it easy to find and understand the command-line implementation for any tool project. The scaffold model is generally recommended, but there's also a "dynamic" model if you need it. See below for examples. |
12 | 12 |
|
13 | | -Internally, **ts-command-line** is based on [argparse](https://www.npmjs.com/package/argparse) and the Python approach to command-lines. It doesn't provide zillions of alternative syntaxes and bells and whistles. But if you're looking for a simple, robust solution for your command-line, give it a try! |
| 13 | +Internally, the implementation is based on [argparse](https://www.npmjs.com/package/argparse) and the Python approach to command-lines. Compared to other libraries, **ts-command-line** doesn't provide zillions of custom syntaxes and bells and whistles. Instead it aims to be a simple, consistent, and professional solution for your command-line tool. Give it a try! |
14 | 14 |
|
15 | 15 |
|
16 | 16 | ### Some Terminology |
|
0 commit comments