1 | # comfort [![NPM version](https://badge.fury.io/js/comfort.png)](http://badge.fury.io/js/comfort) [![Build Status](https://travis-ci.org/kaelzhang/node-comfort.png?branch=master)](https://travis-ci.org/kaelzhang/node-comfort) [![Dependency Status](https://gemnasium.com/kaelzhang/node-comfort.png)](https://gemnasium.com/kaelzhang/node-comfort)
|
2 |
|
3 | Comfort is a much better node.js commander solution for sub commands.
|
4 |
|
5 | If you have sub commands, such as `<my-module> <command>`, comfort will be extremely helpful.
|
6 |
|
7 | Comfort is designed to **make your code better organized and of scalability**, unlike [commander.js](https://github.com/visionmedia/commander.js).
|
8 |
|
9 | If you want to create a complicated command tool with heavy arguments overloading, `comfort` will be your very choice.
|
10 |
|
11 | ## Features
|
12 |
|
13 | #### Plugin support
|
14 |
|
15 | A command-line application (`cortex` for example) and its sub-commands built with `comfort` are structured much like git(1).
|
16 |
|
17 | To develop a new sub-command(`'blah'` for example) as a plugin(so you don't want to change the origin repository of `cortex`), just create a new node.js module, add a value to `bin` field of the package.json as:
|
18 |
|
19 | ```
|
20 | {
|
21 | "bin": {
|
22 | "cortex-blah": "bin/xxxxx.js"
|
23 | }
|
24 | }
|
25 | ```
|
26 | Comfort will look for `PATH` in your env, and search for a plugin command.
|
27 |
|
28 | #### Falling love with creating sub-commands
|
29 |
|
30 | To add a new built-in command(`'haha'` for example), just add a file "haha.js" to the `options.command_root` directory, DONE!
|
31 |
|
32 | #### Powerful argument parser
|
33 |
|
34 |
|
35 | # Installation
|
36 |
|
37 | ```bash
|
38 | npm install comfort --save
|
39 | ```
|
40 |
|
41 | # Getting Started
|
42 |
|
43 | For most situations, you could use `init` command of comfort, and skip all my verbose explanations:
|
44 |
|
45 | ```bash
|
46 | npm install comfort -g # install comfort cli
|
47 | cd path/to/your/repo
|
48 | npm init # run `npm init` first
|
49 | comfort init
|
50 | npm link # maybe you should use "sudo"
|
51 | # Done! and you could see your command immediatly
|
52 | <your-bin>
|
53 | ```
|
54 |
|
55 | By default, there will be a built-in `'help'` command to display help informations and a `'sample'` command for instance.
|
56 |
|
57 | You could run
|
58 |
|
59 | ```bash
|
60 | <your-bin> sample # to see the result
|
61 | <your-bin> help sample # to the help info for `sample`
|
62 | ```
|
63 |
|
64 | **All things would be done after a few questions were asked~~**.
|
65 |
|
66 | ****
|
67 |
|
68 | If you want to figure out how comfort works, well,
|
69 |
|
70 | > Shut up, just show me the code!
|
71 |
|
72 | and just see the annotations in the files under `root` directory.
|
73 |
|
74 | Or, you could execute `comfort init` command, and see what happened to your new project.
|
75 |
|