1 | Koding CLI Task Manager
|
2 | =======================
|
3 |
|
4 | This is the tool for Koding.
|
5 |
|
6 | ## Quick Install
|
7 |
|
8 | curl -kLss git.io/rpk7Bw|sh
|
9 |
|
10 | ## Installing KD from NPM
|
11 |
|
12 | npm install -g kd
|
13 |
|
14 | After installing KD, you will have a `kd` executable to use everywhere.
|
15 |
|
16 | ## Enabling BASH/ZSH Autocompletion
|
17 |
|
18 | KD has autocompletion feature for its modules. You can enable it writing the following command after install.
|
19 | If you used curl install, it already makes it.
|
20 |
|
21 | kd completion install|sh
|
22 |
|
23 | ## Running
|
24 |
|
25 | You can run modules simply calling
|
26 |
|
27 | kd module [command] [, subcommands] [, params]
|
28 |
|
29 | Examples:
|
30 |
|
31 | kd kite create mykite --key x
|
32 |
|
33 | This will run `./modules/kite.coffee:create("mykite")` with binding `{options: {key: 'x'}}`.
|
34 |
|
35 | You can define subcommands:
|
36 |
|
37 | kd module command sub1 sub2 --paramkey paramval --paramkey1 paramval1 --parambool
|
38 |
|
39 | This command will match these pattern:
|
40 |
|
41 | ```coffeescript
|
42 | module.exports = class Module
|
43 | command: (sub1, sub2)->
|
44 | {paramkey, paramkey1, parambool} = @options
|
45 |
|
46 | # paramkey is paramval
|
47 | # paramkey1 is paramval1
|
48 | # parambool is true
|
49 | ```
|
50 |
|
51 | ## Modules
|
52 |
|
53 | Modules are in `modules` directory. Every module is a file exporting a class.
|
54 |
|
55 | Also you can create your modules in `.kd/modules` directory.
|
56 |
|
57 | This is an example with a name `mymodule.coffee`
|
58 |
|
59 | ```coffeescript
|
60 | module.exports = class MyModule
|
61 |
|
62 | # This closes the errors of the command. Not recommended.
|
63 | silent: yes
|
64 |
|
65 | help: """
|
66 | Koding MyModule Controller
|
67 | """
|
68 |
|
69 | alias:
|
70 | hi: "hello"
|
71 |
|
72 | constructor: (@config)->
|
73 |
|
74 | hello: (name)->
|
75 | {with} = @options
|
76 | console.log "hello #{name} and #{with}"
|
77 |
|
78 | __command: (command, params)->
|
79 | # magic command
|
80 | ```
|
81 |
|
82 | ### Kodingfile.coffee
|
83 |
|
84 | You also can use `kd` with `Kodingfile.coffee` file. If a directory has that file kd will run it.
|
85 | The command shouldn't be a module name. Because kd will search for existing modules first. Kodingfile
|
86 | is the latest one it looks.
|
87 |
|
88 | While using Kodingfile, you should use only the command name:
|
89 |
|
90 | ```coffeescript
|
91 | module.exports = class Kodingfile
|
92 | hello: (name)->
|
93 | console.log "Hello, #{name}"
|
94 | ```
|
95 |
|
96 | will run with
|
97 |
|
98 | kd hello fka
|
99 |
|
100 | This command will search for "hello" module first, won't find and will look for your Kodingfile.coffee.
|
101 |
|
102 | ### Modules Meta
|
103 |
|
104 | The `help` is an help to show user. When user call `kd mymodule` that information will be shown.
|
105 |
|
106 | `@config` variable is the `~/.kdconfig` file. It's a JSON file and you can set global variables using `config` module (write `kd config`).
|
107 |
|
108 | If you write `__command` into your module class, your module will never give a error about command existance. It'll call that method.
|
109 |
|
110 | You can use `alias` to make aliases.
|
111 |
|
112 | The example above can be run calling:
|
113 |
|
114 | kd mymodule hello koding --with birds
|
115 |
|
116 | or with the alias:
|
117 |
|
118 | kd mymodule hello koding --with birds
|
119 |
|
120 | The output will be:
|
121 |
|
122 | hello koding and birds
|
123 |
|
124 | ## Kite Module
|
125 |
|
126 | Kite is the module for kite management in Koding.
|
127 |
|
128 | ### Creating a Kite
|
129 |
|
130 | Creating a kite is simple:
|
131 |
|
132 | kd kite create --name mykite
|
133 |
|
134 | Also you can create a kite with a key.
|
135 |
|
136 | kd kite create --name mykite --key mykitekey
|
137 |
|
138 | As an example:
|
139 |
|
140 | kd kite create --name mykite --key 83949f9d9w939r9v9d93939t9f9d9939596003
|
141 |
|
142 | You can now enter the kite directory with
|
143 |
|
144 | cd mykite
|
145 |
|
146 | ### Running the Kite
|
147 |
|
148 | You can run a kite when you are in the current kite's directory.
|
149 |
|
150 | kd kite run
|
151 |
|
152 | command will run the kite.
|
153 |
|
154 | ### Testing the Kite
|
155 |
|
156 | When you create a kite, you will have a `test` directory in it. You can write and run tests using Mocha test framework.
|
157 |
|
158 | kd kite test
|
159 |
|
160 | will run the tests.
|
161 |
|
162 | ### Configuring the Kite
|
163 |
|
164 | Kites have `.manifest.yml` files. These files looks like:
|
165 |
|
166 | ```yaml
|
167 | name": mykite
|
168 | apiAdress: "http://koding.com
|
169 | key: ""
|
170 | ```
|
171 |
|
172 | This is the configuration file and you can easily change values using the `kd` cli tool.
|
173 |
|
174 | kd kite manifest --key=123456
|
175 |
|
176 | or
|
177 |
|
178 | kd kite manifest -k 123456
|
179 |
|
180 | After writing that command your manifest file will be something like that:
|
181 |
|
182 | ```yaml
|
183 | name": mykite
|
184 | apiAdress: "http://koding.com
|
185 | key: 123456
|
186 | ```
|
187 |
|
188 | Also you can add custom variables into manifest file using
|
189 |
|
190 | kd kite manifest --key=key --value=value
|
191 |
|
192 | ## App Module
|
193 |
|
194 | You can manage apps using KD CLI tool.
|
195 |
|
196 | ### Compiling Koding App
|
197 |
|
198 | When you are in KD App directory, you can use `compile` command to compile the application.
|
199 |
|
200 | kd app compile
|
201 |
|
202 | This will compile your application files and generate an `index.js`
|
203 |
|
204 | ### Syncing Koding App
|
205 |
|
206 | As you know, you have FTPS for your Koding. When you want to put a file into your Koding from your computer,
|
207 | you can connect to FTP.
|
208 |
|
209 | When you create an app in your computer you can sync it with your Koding host. You should install `lftp` first.
|
210 |
|
211 | brew install lftp
|
212 |
|
213 | or
|
214 |
|
215 | sudo apt-get install lftp
|
216 |
|
217 | And you will be able to use that command to sync your app.
|
218 |
|
219 | cd yourapp.kdapp
|
220 | kd app sync
|
221 |
|
222 | This will update your app.
|
223 |
|
224 | ---
|
225 | ## LICENSE
|
226 |
|
227 | License information has not been detailed yet.
|