1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
|
%global _empty_manifest_terminate_build 0
Name: python-milc
Version: 1.6.6
Release: 1
Summary: Opinionated Batteries-Included Python 3 CLI Framework.
License: MIT License
URL: https://milc.clueboard.co/
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/92/c0/3377091d68d98f7448e9e3624d6692548efcd98917cc48a69efb650a3eb4/milc-1.6.6.tar.gz
BuildArch: noarch
Requires: python3-appdirs
Requires: python3-argcomplete
Requires: python3-colorama
Requires: python3-halo
Requires: python3-spinners
%description
# MILC - An Opinionated Batteries-Included Python 3 CLI Framework
MILC is a framework for writing CLI applications in Python 3.6+. It gives you
all the features users expect from a modern CLI tool out of the box:
* CLI Argument Parsing, with or without subcommands
* Automatic tab-completion support through [argcomplete](https://github.com/kislyuk/argcomplete)
* Configuration file which can be overridden by CLI options
* ANSI color support- even on Windows- with [colorama](https://github.com/tartley/colorama)
* Logging to stderr and/or a file, with ANSI colors
* Easy method for printing to stdout with ANSI colors
* Labeling log output with colored emoji to easily distinguish message types
* Thread safety
* More than 60 built-in [spinners](https://github.com/manrajgrover/py-spinners) with the ability to add your own
# Installation
MILC is available on pypi, you can use pip to install it:
python3 -m pip install milc
# ChangeLog and Breaking Changes
MILC follows [Semantic Versioning](https://semver.org/). You can view the [full changelog](https://github.com/clueboard/milc/blob/master/CHANGELOG.rst), or you can see a list of why we made major or minor releases on the [Breaking Changes](https://milc.clueboard.co/#/breaking_changes) page.
# Documentation
Full documentation is on the web: <https://milc.clueboard.co/>
## Reporting Bugs and Requesting Features
Please let us know about any bugs and/or feature requests you have: <https://github.com/clueboard/milc/issues>
## Short Example
```python
from milc import cli
@cli.argument('-c', '--comma', arg_only=True, action='store_boolean', default=True, help='comma in output')
@cli.argument('-n', '--name', default='World', help='Name to greet')
@cli.entrypoint('My useful CLI tool.')
def main(cli):
comma = ',' if cli.args.comma else ''
cli.log.info('Hello%s %s!', comma, cli.config.general.name)
if __name__ == '__main__':
cli.run()
```
### Output
```
$ ./hello
ℹ Hello, World!
$ ./hello --no-unicode
INFO Hello, World!
$ ./hello --no-comma
ℹ Hello World!
$ ./hello -h
usage: hello [-h] [-V] [-v] [--datetime-fmt GENERAL_DATETIME_FMT]
[--log-fmt GENERAL_LOG_FMT] [--log-file-fmt GENERAL_LOG_FILE_FMT]
[--log-file GENERAL_LOG_FILE] [--color] [--no-color]
[--config-file GENERAL_CONFIG_FILE] [--save-config]
[-n GENERAL_NAME] [-c] [--no-comma]
Greet a user.
optional arguments:
-h, --help show this help message and exit
-V, --version Display the version and exit
-v, --verbose Make the logging more verbose
--datetime-fmt GENERAL_DATETIME_FMT
Format string for datetimes
--log-fmt GENERAL_LOG_FMT
Format string for printed log output
--log-file-fmt GENERAL_LOG_FILE_FMT
Format string for log file.
--log-file GENERAL_LOG_FILE
File to write log messages to
--color Enable color in output
--no-color Disable color in output
--config-file GENERAL_CONFIG_FILE
The config file to read and/or write
--save-config Save the running configuration to the config file
-n GENERAL_NAME, --name GENERAL_NAME
Name to greet
-c, --comma Enable comma in output
--no-comma Disable comma in output
```
# Why MILC?
Because life is too short to integrate this stuff yourself, and writing
good CLIs with comprehensive functionality is harder than it needs to be.
Most of the other CLI frameworks are missing a piece of the puzzle. Maybe
they have argument parsing but no config file story. Maybe they have a
good story around arguments and config but don't handle logging at all.
You know that you're doing the same integration work that almost everyone
else is doing in their own app. Why do we duplicate so much effort?
MILC is my answer to that. It implements a common set of CLI tools that
pretty much every project I have ever worked on either needed or would
have benefited from. Included in MILC are answers to problems you didn't
know you have:
* Config file saving and parsing
* Automatically overriding config options with CLI arguments
* Automatic verbose (-v) support
* Automatic log support
* Built-in flags for formatting log messages and log date formats
* Support for boolean arguments (define --foo and get --no-foo for free)
* Battle tested and used by hundreds of users every single day
You may not use all of these features yourself, but you will have users
who are very glad these options are available when they need them.
# Contributing
Contributions are welcome! You don't need to open an issue first, if
you've developed a new feature or fixed a bug in MILC simply open
a PR and we'll review it.
Please follow this checklist before submitting a PR:
* [ ] Format your code: `yapf -i -r .`
* [ ] Generate docs: `./generate_docs`
* [ ] Add any new doc files to the `nav` section of `mkdocs.yml`
* [ ] Run tests: `./ci_tests`
# FAQ
## What does MILC stand for?
MILC was originally the CLI Context Manager, or CLI Manager, but CLICM was too close to [click](https://click.palletsprojects.com/) and CLIM was already taken on PyPi. Reversing CLIM gave me a name I liked and had opportunities for puns, so I went with it.
## Why decorators instead of parsing function signatures?
Because I believe in writing good CLI tools.
Before writing MILC I saw variations of the same story over and over. "I
started with {Click,Docopt,Whatever} but after a while I ended up just
going back to argparse." In pretty much every case as the complexity of
their program grew they needed to do things argparse made easy and their
framework made hard.
MILC attempts to solve this by embracing the complexity of argparse. It
handles the drudgery of setting up argparse for you, but gives you an
elegant means to control that complexity when you need to. When your
CLI framework relies on parsing function signatures you are necessarily
limited in what you can do. Function annotations make this a little
better but they are not a full solution to the problem.
If you care about writing good CLI tools (and I hope you do) you will want
more control over the behavior of your program than Click or Docopt give you.
## Why Not Some Other CLI Framework Instead?
Whenever you release a new framework the first question you'll be asked is
why you didn't just use one of the existing options instead.
As I surveyed the other tools I found that most of them only solve part of
the problem, not the whole problem. Those that solve the whole problem are
very hard to use or get started with, or are otherwise very heavyweight. I
wanted a comprehensive framework that was easy to get started with.
If you'd like to see how MILC compares to other tools see
[COMPARISONS.md](COMPARISONS.md).
%package -n python3-milc
Summary: Opinionated Batteries-Included Python 3 CLI Framework.
Provides: python-milc
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-milc
# MILC - An Opinionated Batteries-Included Python 3 CLI Framework
MILC is a framework for writing CLI applications in Python 3.6+. It gives you
all the features users expect from a modern CLI tool out of the box:
* CLI Argument Parsing, with or without subcommands
* Automatic tab-completion support through [argcomplete](https://github.com/kislyuk/argcomplete)
* Configuration file which can be overridden by CLI options
* ANSI color support- even on Windows- with [colorama](https://github.com/tartley/colorama)
* Logging to stderr and/or a file, with ANSI colors
* Easy method for printing to stdout with ANSI colors
* Labeling log output with colored emoji to easily distinguish message types
* Thread safety
* More than 60 built-in [spinners](https://github.com/manrajgrover/py-spinners) with the ability to add your own
# Installation
MILC is available on pypi, you can use pip to install it:
python3 -m pip install milc
# ChangeLog and Breaking Changes
MILC follows [Semantic Versioning](https://semver.org/). You can view the [full changelog](https://github.com/clueboard/milc/blob/master/CHANGELOG.rst), or you can see a list of why we made major or minor releases on the [Breaking Changes](https://milc.clueboard.co/#/breaking_changes) page.
# Documentation
Full documentation is on the web: <https://milc.clueboard.co/>
## Reporting Bugs and Requesting Features
Please let us know about any bugs and/or feature requests you have: <https://github.com/clueboard/milc/issues>
## Short Example
```python
from milc import cli
@cli.argument('-c', '--comma', arg_only=True, action='store_boolean', default=True, help='comma in output')
@cli.argument('-n', '--name', default='World', help='Name to greet')
@cli.entrypoint('My useful CLI tool.')
def main(cli):
comma = ',' if cli.args.comma else ''
cli.log.info('Hello%s %s!', comma, cli.config.general.name)
if __name__ == '__main__':
cli.run()
```
### Output
```
$ ./hello
ℹ Hello, World!
$ ./hello --no-unicode
INFO Hello, World!
$ ./hello --no-comma
ℹ Hello World!
$ ./hello -h
usage: hello [-h] [-V] [-v] [--datetime-fmt GENERAL_DATETIME_FMT]
[--log-fmt GENERAL_LOG_FMT] [--log-file-fmt GENERAL_LOG_FILE_FMT]
[--log-file GENERAL_LOG_FILE] [--color] [--no-color]
[--config-file GENERAL_CONFIG_FILE] [--save-config]
[-n GENERAL_NAME] [-c] [--no-comma]
Greet a user.
optional arguments:
-h, --help show this help message and exit
-V, --version Display the version and exit
-v, --verbose Make the logging more verbose
--datetime-fmt GENERAL_DATETIME_FMT
Format string for datetimes
--log-fmt GENERAL_LOG_FMT
Format string for printed log output
--log-file-fmt GENERAL_LOG_FILE_FMT
Format string for log file.
--log-file GENERAL_LOG_FILE
File to write log messages to
--color Enable color in output
--no-color Disable color in output
--config-file GENERAL_CONFIG_FILE
The config file to read and/or write
--save-config Save the running configuration to the config file
-n GENERAL_NAME, --name GENERAL_NAME
Name to greet
-c, --comma Enable comma in output
--no-comma Disable comma in output
```
# Why MILC?
Because life is too short to integrate this stuff yourself, and writing
good CLIs with comprehensive functionality is harder than it needs to be.
Most of the other CLI frameworks are missing a piece of the puzzle. Maybe
they have argument parsing but no config file story. Maybe they have a
good story around arguments and config but don't handle logging at all.
You know that you're doing the same integration work that almost everyone
else is doing in their own app. Why do we duplicate so much effort?
MILC is my answer to that. It implements a common set of CLI tools that
pretty much every project I have ever worked on either needed or would
have benefited from. Included in MILC are answers to problems you didn't
know you have:
* Config file saving and parsing
* Automatically overriding config options with CLI arguments
* Automatic verbose (-v) support
* Automatic log support
* Built-in flags for formatting log messages and log date formats
* Support for boolean arguments (define --foo and get --no-foo for free)
* Battle tested and used by hundreds of users every single day
You may not use all of these features yourself, but you will have users
who are very glad these options are available when they need them.
# Contributing
Contributions are welcome! You don't need to open an issue first, if
you've developed a new feature or fixed a bug in MILC simply open
a PR and we'll review it.
Please follow this checklist before submitting a PR:
* [ ] Format your code: `yapf -i -r .`
* [ ] Generate docs: `./generate_docs`
* [ ] Add any new doc files to the `nav` section of `mkdocs.yml`
* [ ] Run tests: `./ci_tests`
# FAQ
## What does MILC stand for?
MILC was originally the CLI Context Manager, or CLI Manager, but CLICM was too close to [click](https://click.palletsprojects.com/) and CLIM was already taken on PyPi. Reversing CLIM gave me a name I liked and had opportunities for puns, so I went with it.
## Why decorators instead of parsing function signatures?
Because I believe in writing good CLI tools.
Before writing MILC I saw variations of the same story over and over. "I
started with {Click,Docopt,Whatever} but after a while I ended up just
going back to argparse." In pretty much every case as the complexity of
their program grew they needed to do things argparse made easy and their
framework made hard.
MILC attempts to solve this by embracing the complexity of argparse. It
handles the drudgery of setting up argparse for you, but gives you an
elegant means to control that complexity when you need to. When your
CLI framework relies on parsing function signatures you are necessarily
limited in what you can do. Function annotations make this a little
better but they are not a full solution to the problem.
If you care about writing good CLI tools (and I hope you do) you will want
more control over the behavior of your program than Click or Docopt give you.
## Why Not Some Other CLI Framework Instead?
Whenever you release a new framework the first question you'll be asked is
why you didn't just use one of the existing options instead.
As I surveyed the other tools I found that most of them only solve part of
the problem, not the whole problem. Those that solve the whole problem are
very hard to use or get started with, or are otherwise very heavyweight. I
wanted a comprehensive framework that was easy to get started with.
If you'd like to see how MILC compares to other tools see
[COMPARISONS.md](COMPARISONS.md).
%package help
Summary: Development documents and examples for milc
Provides: python3-milc-doc
%description help
# MILC - An Opinionated Batteries-Included Python 3 CLI Framework
MILC is a framework for writing CLI applications in Python 3.6+. It gives you
all the features users expect from a modern CLI tool out of the box:
* CLI Argument Parsing, with or without subcommands
* Automatic tab-completion support through [argcomplete](https://github.com/kislyuk/argcomplete)
* Configuration file which can be overridden by CLI options
* ANSI color support- even on Windows- with [colorama](https://github.com/tartley/colorama)
* Logging to stderr and/or a file, with ANSI colors
* Easy method for printing to stdout with ANSI colors
* Labeling log output with colored emoji to easily distinguish message types
* Thread safety
* More than 60 built-in [spinners](https://github.com/manrajgrover/py-spinners) with the ability to add your own
# Installation
MILC is available on pypi, you can use pip to install it:
python3 -m pip install milc
# ChangeLog and Breaking Changes
MILC follows [Semantic Versioning](https://semver.org/). You can view the [full changelog](https://github.com/clueboard/milc/blob/master/CHANGELOG.rst), or you can see a list of why we made major or minor releases on the [Breaking Changes](https://milc.clueboard.co/#/breaking_changes) page.
# Documentation
Full documentation is on the web: <https://milc.clueboard.co/>
## Reporting Bugs and Requesting Features
Please let us know about any bugs and/or feature requests you have: <https://github.com/clueboard/milc/issues>
## Short Example
```python
from milc import cli
@cli.argument('-c', '--comma', arg_only=True, action='store_boolean', default=True, help='comma in output')
@cli.argument('-n', '--name', default='World', help='Name to greet')
@cli.entrypoint('My useful CLI tool.')
def main(cli):
comma = ',' if cli.args.comma else ''
cli.log.info('Hello%s %s!', comma, cli.config.general.name)
if __name__ == '__main__':
cli.run()
```
### Output
```
$ ./hello
ℹ Hello, World!
$ ./hello --no-unicode
INFO Hello, World!
$ ./hello --no-comma
ℹ Hello World!
$ ./hello -h
usage: hello [-h] [-V] [-v] [--datetime-fmt GENERAL_DATETIME_FMT]
[--log-fmt GENERAL_LOG_FMT] [--log-file-fmt GENERAL_LOG_FILE_FMT]
[--log-file GENERAL_LOG_FILE] [--color] [--no-color]
[--config-file GENERAL_CONFIG_FILE] [--save-config]
[-n GENERAL_NAME] [-c] [--no-comma]
Greet a user.
optional arguments:
-h, --help show this help message and exit
-V, --version Display the version and exit
-v, --verbose Make the logging more verbose
--datetime-fmt GENERAL_DATETIME_FMT
Format string for datetimes
--log-fmt GENERAL_LOG_FMT
Format string for printed log output
--log-file-fmt GENERAL_LOG_FILE_FMT
Format string for log file.
--log-file GENERAL_LOG_FILE
File to write log messages to
--color Enable color in output
--no-color Disable color in output
--config-file GENERAL_CONFIG_FILE
The config file to read and/or write
--save-config Save the running configuration to the config file
-n GENERAL_NAME, --name GENERAL_NAME
Name to greet
-c, --comma Enable comma in output
--no-comma Disable comma in output
```
# Why MILC?
Because life is too short to integrate this stuff yourself, and writing
good CLIs with comprehensive functionality is harder than it needs to be.
Most of the other CLI frameworks are missing a piece of the puzzle. Maybe
they have argument parsing but no config file story. Maybe they have a
good story around arguments and config but don't handle logging at all.
You know that you're doing the same integration work that almost everyone
else is doing in their own app. Why do we duplicate so much effort?
MILC is my answer to that. It implements a common set of CLI tools that
pretty much every project I have ever worked on either needed or would
have benefited from. Included in MILC are answers to problems you didn't
know you have:
* Config file saving and parsing
* Automatically overriding config options with CLI arguments
* Automatic verbose (-v) support
* Automatic log support
* Built-in flags for formatting log messages and log date formats
* Support for boolean arguments (define --foo and get --no-foo for free)
* Battle tested and used by hundreds of users every single day
You may not use all of these features yourself, but you will have users
who are very glad these options are available when they need them.
# Contributing
Contributions are welcome! You don't need to open an issue first, if
you've developed a new feature or fixed a bug in MILC simply open
a PR and we'll review it.
Please follow this checklist before submitting a PR:
* [ ] Format your code: `yapf -i -r .`
* [ ] Generate docs: `./generate_docs`
* [ ] Add any new doc files to the `nav` section of `mkdocs.yml`
* [ ] Run tests: `./ci_tests`
# FAQ
## What does MILC stand for?
MILC was originally the CLI Context Manager, or CLI Manager, but CLICM was too close to [click](https://click.palletsprojects.com/) and CLIM was already taken on PyPi. Reversing CLIM gave me a name I liked and had opportunities for puns, so I went with it.
## Why decorators instead of parsing function signatures?
Because I believe in writing good CLI tools.
Before writing MILC I saw variations of the same story over and over. "I
started with {Click,Docopt,Whatever} but after a while I ended up just
going back to argparse." In pretty much every case as the complexity of
their program grew they needed to do things argparse made easy and their
framework made hard.
MILC attempts to solve this by embracing the complexity of argparse. It
handles the drudgery of setting up argparse for you, but gives you an
elegant means to control that complexity when you need to. When your
CLI framework relies on parsing function signatures you are necessarily
limited in what you can do. Function annotations make this a little
better but they are not a full solution to the problem.
If you care about writing good CLI tools (and I hope you do) you will want
more control over the behavior of your program than Click or Docopt give you.
## Why Not Some Other CLI Framework Instead?
Whenever you release a new framework the first question you'll be asked is
why you didn't just use one of the existing options instead.
As I surveyed the other tools I found that most of them only solve part of
the problem, not the whole problem. Those that solve the whole problem are
very hard to use or get started with, or are otherwise very heavyweight. I
wanted a comprehensive framework that was easy to get started with.
If you'd like to see how MILC compares to other tools see
[COMPARISONS.md](COMPARISONS.md).
%prep
%autosetup -n milc-1.6.6
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-milc -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.6.6-1
- Package Spec generated
|