|
15 | 15 | g.public_templates_path = os.path.join(g.catsup_path, 'templates') |
16 | 16 | g.cwdpath = os.path.abspath('.') |
17 | 17 |
|
18 | | -try: |
19 | | - import catsup |
20 | | -except ImportError: |
21 | | - import site |
22 | | - site.addsitedir(os.path.dirname(g.catsup_path)) |
| 18 | +import catsup |
23 | 19 |
|
24 | | -doc = """catsup v%s |
| 20 | +doc = """Catsup v%s |
25 | 21 |
|
26 | 22 | Usage: |
27 | 23 | catsup init [<path>] |
|
32 | 28 | catsup server [-s <file>|--settings=<file>] [-p <port>|--port=<port>] |
33 | 29 | catsup webhook [-s <file>|--settings=<file>] [-p <port>|--port=<port>] |
34 | 30 | catsup watch [-s <file>|--settings=<file>] |
35 | | - catsup themes |
36 | 31 | catsup clean [-s <file>|--settings=<file>] |
| 32 | + catsup themes |
37 | 33 | catsup install <theme> |
38 | 34 | catsup -h | --help |
39 | 35 | catsup --version |
@@ -145,8 +141,8 @@ def server(settings, port): |
145 | 141 | -p --port=<port> specify the server port. [default: 8888] |
146 | 142 | """ |
147 | 143 | import catsup.server |
148 | | - server = catsup.server.PreviewServer(settings, port) |
149 | | - server.run() |
| 144 | + preview_server = catsup.server.PreviewServer(settings, port) |
| 145 | + preview_server.run() |
150 | 146 |
|
151 | 147 |
|
152 | 148 | @parguments.command |
@@ -192,51 +188,48 @@ def watch(settings): |
192 | 188 |
|
193 | 189 |
|
194 | 190 | @parguments.command |
195 | | -def themes(): |
| 191 | +def clean(settings): |
196 | 192 | """ |
197 | 193 | Usage: |
198 | | - catsup themes |
| 194 | + catsup clean [-s <file>|--settings=<file>] |
199 | 195 |
|
200 | 196 | Options: |
201 | 197 | -h --help Show this screen and exit. |
| 198 | + -s --settings=<file> specify a setting file. [default: config.json] |
202 | 199 | """ |
203 | | - import catsup.parser.themes |
204 | | - catsup.parser.themes.list() |
| 200 | + import shutil |
| 201 | + import catsup.parser.config |
| 202 | + config = catsup.parser.config(settings) |
| 203 | + |
| 204 | + for path in [config.config.static_output, config.config.output]: |
| 205 | + if os.path.exists(path): |
| 206 | + shutil.rmtree(path) |
205 | 207 |
|
206 | 208 |
|
207 | 209 | @parguments.command |
208 | | -def clean(settings): |
| 210 | +def themes(): |
209 | 211 | """ |
210 | 212 | Usage: |
211 | | - catsup clean [-s <file>|--settings=<file>] |
| 213 | + catsup themes |
212 | 214 |
|
213 | 215 | Options: |
214 | | - -s --settings=<file> specify a setting file. [default: config.json] |
215 | 216 | -h --help Show this screen and exit. |
216 | 217 | """ |
217 | | - import catsup.parser.config |
218 | | - import shutil |
219 | | - config = catsup.parser.config(settings) |
220 | | - if os.path.exists(".catsup-cache"): |
221 | | - shutil.rmtree(".catsup-cache") |
222 | | - logger.info("Removed cache folder.") |
223 | | - output_path = config.config.output |
224 | | - if os.path.exists(output_path): |
225 | | - shutil.rmtree(output_path) |
226 | | - logger.info("Removed output folder.") |
| 218 | + from catsup.parser.themes import list_themes |
| 219 | + list_themes() |
227 | 220 |
|
228 | 221 |
|
229 | 222 | @parguments.command |
230 | | -def install(theme): |
| 223 | +def install(name): |
231 | 224 | """ |
232 | 225 | Usage: |
233 | | - catsup install <theme> |
| 226 | + catsup install <name> |
234 | 227 |
|
235 | 228 | Options: |
236 | 229 | -h --help Show this screen and exit. |
237 | 230 | """ |
238 | | - import catsup.parser.themes |
239 | | - catsup.parser.themes.install(path=theme) |
| 231 | + from catsup.themes.install import install_theme |
| 232 | + install_theme(name=name) |
240 | 233 |
|
241 | 234 |
|
242 | 235 | def main(): |
|
0 commit comments