dldinternet-mixlib-thor 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/ChangeLog.md +4 -0
- data/Gemfile +7 -0
- data/LICENSE +201 -0
- data/LICENSE.txt +203 -0
- data/README.md +2 -0
- data/Rakefile +30 -0
- data/atlassian-ide-plugin.xml +6 -0
- data/dldinternet-mixlib-thor.gemspec +31 -0
- data/lib/dldinternet/formatters.rb +6 -0
- data/lib/dldinternet/formatters/awesome.rb +24 -0
- data/lib/dldinternet/formatters/basic.rb +34 -0
- data/lib/dldinternet/formatters/colors.rb +31 -0
- data/lib/dldinternet/formatters/errors.rb +9 -0
- data/lib/dldinternet/formatters/table.rb +115 -0
- data/lib/dldinternet/thor/command.rb +86 -0
- data/lib/dldinternet/thor/mixins/no_commands.rb +234 -0
- data/lib/dldinternet/thor/version.rb +18 -0
- metadata +213 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9e8af4011e27fd5729b0651cbe251c466c4adfc0
|
4
|
+
data.tar.gz: f373ef8a1beea33b902119c12bac62b86c2fa4df
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 351f0827f4677648850e9c0a0164e1a7536595f1bd705bcfa376dd8b9be49d116b167a959a213c027fb5466f20d817bdba7c0754b88b2821a4b3b7ceadc19ec6
|
7
|
+
data.tar.gz: 88f596d749e36160b181fd708c3d78859757d456a5e1c4f3a470455a1615056d6b4a99ea9594abb8638957b61f6107ab46a9ac1d767027dc9ea5e88ca75ff994
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
.ruby-version
|
31
|
+
.ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
*.iml
|
data/ChangeLog.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
Copyright (c) 2014 Christo De Lange
|
2
|
+
|
3
|
+
Apache License
|
4
|
+
Version 2.0, January 2004
|
5
|
+
http://www.apache.org/licenses/
|
6
|
+
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8
|
+
|
9
|
+
1. Definitions.
|
10
|
+
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
13
|
+
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
15
|
+
the copyright owner that is granting the License.
|
16
|
+
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
18
|
+
other entities that control, are controlled by, or are under common
|
19
|
+
control with that entity. For the purposes of this definition,
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
21
|
+
direction or management of such entity, whether by contract or
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
24
|
+
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
26
|
+
exercising permissions granted by this License.
|
27
|
+
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
29
|
+
including but not limited to software source code, documentation
|
30
|
+
source, and configuration files.
|
31
|
+
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
33
|
+
transformation or translation of a Source form, including but
|
34
|
+
not limited to compiled object code, generated documentation,
|
35
|
+
and conversions to other media types.
|
36
|
+
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
38
|
+
Object form, made available under the License, as indicated by a
|
39
|
+
copyright notice that is included in or attached to the work
|
40
|
+
(an example is provided in the Appendix below).
|
41
|
+
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
48
|
+
the Work and Derivative Works thereof.
|
49
|
+
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
51
|
+
the original version of the Work and any modifications or additions
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
63
|
+
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
66
|
+
subsequently incorporated within the Work.
|
67
|
+
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
74
|
+
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
80
|
+
where such license applies only to those patent claims licensable
|
81
|
+
by such Contributor that are necessarily infringed by their
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
84
|
+
institute patent litigation against any entity (including a
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
87
|
+
or contributory patent infringement, then any patent licenses
|
88
|
+
granted to You under this License for that Work shall terminate
|
89
|
+
as of the date such litigation is filed.
|
90
|
+
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
93
|
+
modifications, and in Source or Object form, provided that You
|
94
|
+
meet the following conditions:
|
95
|
+
|
96
|
+
(a) You must give any other recipients of the Work or
|
97
|
+
Derivative Works a copy of this License; and
|
98
|
+
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
100
|
+
stating that You changed the files; and
|
101
|
+
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
104
|
+
attribution notices from the Source form of the Work,
|
105
|
+
excluding those notices that do not pertain to any part of
|
106
|
+
the Derivative Works; and
|
107
|
+
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
110
|
+
include a readable copy of the attribution notices contained
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
113
|
+
of the following places: within a NOTICE text file distributed
|
114
|
+
as part of the Derivative Works; within the Source form or
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
116
|
+
within a display generated by the Derivative Works, if and
|
117
|
+
wherever such third-party notices normally appear. The contents
|
118
|
+
of the NOTICE file are for informational purposes only and
|
119
|
+
do not modify the License. You may add Your own attribution
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
122
|
+
that such additional attribution notices cannot be construed
|
123
|
+
as modifying the License.
|
124
|
+
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
126
|
+
may provide additional or different license terms and conditions
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
130
|
+
the conditions stated in this License.
|
131
|
+
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
135
|
+
this License, without any additional terms or conditions.
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
137
|
+
the terms of any separate license agreement you may have executed
|
138
|
+
with Licensor regarding such Contributions.
|
139
|
+
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
142
|
+
except as required for reasonable and customary use in describing the
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
144
|
+
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
154
|
+
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
160
|
+
incidental, or consequential damages of any character arising as a
|
161
|
+
result of this License or out of the use or inability to use the
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
164
|
+
other commercial damages or losses), even if such Contributor
|
165
|
+
has been advised of the possibility of such damages.
|
166
|
+
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
170
|
+
or other liability obligations and/or rights consistent with this
|
171
|
+
License. However, in accepting such obligations, You may act only
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
176
|
+
of your accepting any such warranty or additional liability.
|
177
|
+
|
178
|
+
END OF TERMS AND CONDITIONS
|
179
|
+
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
181
|
+
|
182
|
+
To apply the Apache License to your work, attach the following
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
184
|
+
replaced with your own identifying information. (Don't include
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
186
|
+
comment syntax for the file format. We also recommend that a
|
187
|
+
file or class name and description of purpose be included on the
|
188
|
+
same "printed page" as the copyright notice for easier
|
189
|
+
identification within third-party archives.
|
190
|
+
|
191
|
+
Copyright {yyyy} {name of copyright owner}
|
192
|
+
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
194
|
+
you may not use this file except in compliance with the License.
|
195
|
+
You may obtain a copy of the License at
|
196
|
+
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
198
|
+
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
202
|
+
See the License for the specific language governing permissions and
|
203
|
+
limitations under the License.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler'
|
7
|
+
rescue LoadError => e
|
8
|
+
warn e.message
|
9
|
+
warn "Run `gem install bundler` to install Bundler."
|
10
|
+
exit -1
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
Bundler.setup(:development)
|
15
|
+
rescue Bundler::BundlerError => e
|
16
|
+
warn e.message
|
17
|
+
warn "Run `bundle install` to install missing gems."
|
18
|
+
exit e.status_code
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake'
|
22
|
+
|
23
|
+
require 'rubygems/tasks'
|
24
|
+
Gem::Tasks.new
|
25
|
+
|
26
|
+
require 'cucumber/rake/task'
|
27
|
+
|
28
|
+
Cucumber::Rake::Task.new do |t|
|
29
|
+
t.cucumber_opts = %w[--format pretty]
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/dldinternet/thor/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'dldinternet-mixlib-thor'
|
7
|
+
gem.version = Dldinternet::Mixlib::Thor::VERSION
|
8
|
+
gem.summary = %q{Thor no_commands reuse}
|
9
|
+
gem.description = %q{Thor no_commands reuse}
|
10
|
+
gem.license = 'Apachev2'
|
11
|
+
gem.authors = ['Christo De Lange']
|
12
|
+
gem.email = 'rubygems@dldinternet.com'
|
13
|
+
gem.homepage = 'https://rubygems.org/gems/dldinternet-mixlib-thor'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'thor', '~> 0.19', '>= 0'
|
21
|
+
gem.add_dependency 'awesome_print' #, '~> 1.2'
|
22
|
+
gem.add_dependency 'paint-shortcuts', '>= 0'
|
23
|
+
gem.add_dependency 'dldinternet-mixlib-logging' , '~> 0.5'
|
24
|
+
gem.add_dependency 'inifile' #, '~> '
|
25
|
+
gem.add_dependency 'hashie' #, '~> '
|
26
|
+
gem.add_dependency 'command_line_reporter', '~> 3.3', '>= 3.3.6'
|
27
|
+
|
28
|
+
gem.add_development_dependency 'bundler', '~> 1.0'
|
29
|
+
gem.add_development_dependency 'rake', '~> 10'
|
30
|
+
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'awesome_print'
|
4
|
+
|
5
|
+
module DLDInternet
|
6
|
+
module Formatters
|
7
|
+
# Awesome formatter
|
8
|
+
class Awesome
|
9
|
+
attr_reader :format
|
10
|
+
attr_reader :object
|
11
|
+
attr_reader :title
|
12
|
+
|
13
|
+
def initialize(obj, format, title)
|
14
|
+
@object = obj
|
15
|
+
@format = format
|
16
|
+
@title = title
|
17
|
+
end
|
18
|
+
|
19
|
+
def format_it
|
20
|
+
object.ai
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module DLDInternet
|
7
|
+
module Formatters
|
8
|
+
# Basic formatter
|
9
|
+
class Basic
|
10
|
+
attr_reader :format
|
11
|
+
attr_reader :object
|
12
|
+
attr_reader :title
|
13
|
+
|
14
|
+
def initialize(obj, format, title)
|
15
|
+
@object = obj
|
16
|
+
@format = format
|
17
|
+
@title = title
|
18
|
+
end
|
19
|
+
|
20
|
+
def format_it
|
21
|
+
case format.to_s.downcase
|
22
|
+
when 'json'
|
23
|
+
JSON.pretty_generate(object)
|
24
|
+
when 'yaml'
|
25
|
+
object.to_yaml
|
26
|
+
when 'none'
|
27
|
+
object
|
28
|
+
else
|
29
|
+
object.to_s
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# require 'colorize'
|
4
|
+
require 'paint/shortcuts'
|
5
|
+
Paint.mode = 256
|
6
|
+
def RGB(*args)
|
7
|
+
args
|
8
|
+
end
|
9
|
+
palette = {}
|
10
|
+
[:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white].each do |color|
|
11
|
+
next if String.respond_to?(color)
|
12
|
+
palette[color] = Paint.color(color)
|
13
|
+
palette[:"light_#{color}"] = Paint.color(color, :bright)
|
14
|
+
end
|
15
|
+
palette[:copper] = Paint.color RGB(225, 142, 121)
|
16
|
+
palette[:pancho] = Paint.color RGB(229, 173, 148)
|
17
|
+
# "\\e[38;5;208m\\e[40m$*\\e[0m\\n"
|
18
|
+
palette[:pumpkin] = Paint.color RGB(252, 120, 30)
|
19
|
+
palette[:tango] = Paint.color RGB(240, 108, 23)
|
20
|
+
palette[:light_orange] = Paint.color RGB(248, 132, 127)
|
21
|
+
palette[:salmon] = Paint.color RGB(234, 99, 44)
|
22
|
+
palette[:royal] = Paint.color RGB(76, 114, 230)
|
23
|
+
palette[:cornflower] = Paint.color RGB(104, 136, 234)
|
24
|
+
palette[:cf] = Paint.color RGB(40, 114, 101)
|
25
|
+
palette[:genoa] = Paint.color RGB(40, 114, 101)
|
26
|
+
palette[:trout] = Paint.color RGB(77, 88, 89)
|
27
|
+
palette[:brick] = Paint.color RGB(196, 48, 59)
|
28
|
+
palette[:matisse] = Paint.color RGB(46, 94, 127)
|
29
|
+
palette[:tufts] = Paint.color RGB(56, 137, 202)
|
30
|
+
Paint::SHORTCUTS[:thd] = palette
|
31
|
+
include Paint::Thd::String
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dldinternet/formatters/colors'
|
4
|
+
require 'awesome_print'
|
5
|
+
require 'command_line_reporter'
|
6
|
+
|
7
|
+
module DLDInternet
|
8
|
+
module Formatters
|
9
|
+
# Table formatter
|
10
|
+
# :reek:RepeatedConditional {enabled: false}
|
11
|
+
class Table < DLDInternet::Formatters::Basic
|
12
|
+
include CommandLineReporter
|
13
|
+
|
14
|
+
attr_reader :widths
|
15
|
+
attr_reader :is_a_hash
|
16
|
+
|
17
|
+
def initialize(obj, format, title)
|
18
|
+
super
|
19
|
+
# self.formatter = ''
|
20
|
+
@object = [@object] unless @object.is_a?(Array)
|
21
|
+
@is_a_hash = @object[0].is_a?(Hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
suppress_output
|
26
|
+
|
27
|
+
header(title: @title, align: 'center') if @title
|
28
|
+
|
29
|
+
table border: true, encoding: :ascii do
|
30
|
+
header_row
|
31
|
+
idx = 0
|
32
|
+
@object.each do |obj|
|
33
|
+
obj_row(idx, obj)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
capture_output
|
38
|
+
rescue => exe
|
39
|
+
restore_output
|
40
|
+
raise exe
|
41
|
+
end
|
42
|
+
|
43
|
+
def header_row
|
44
|
+
if @is_a_hash
|
45
|
+
row color: 'light_yellow', bold: true, encoding: :ascii do
|
46
|
+
@object[0].each do |key, _|
|
47
|
+
column key.to_s, width: widths[key]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def obj_row(idx, obj)
|
54
|
+
row color: 'white', bold: false do
|
55
|
+
if @is_a_hash
|
56
|
+
obj.each do |_, val|
|
57
|
+
column val.to_s
|
58
|
+
end
|
59
|
+
else
|
60
|
+
column obj.to_s, width: widths[idx]
|
61
|
+
idx += 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# :reek:DuplicateMethodCall {enabled: false}
|
67
|
+
def widths
|
68
|
+
unless @widths
|
69
|
+
@widths = Hashie::Mash.new
|
70
|
+
if @is_a_hash
|
71
|
+
widths_hash
|
72
|
+
else
|
73
|
+
widths_array
|
74
|
+
end
|
75
|
+
end
|
76
|
+
@widths
|
77
|
+
end
|
78
|
+
|
79
|
+
def widths_array
|
80
|
+
idx = 0
|
81
|
+
@object.each do |val|
|
82
|
+
set_width(idx, val)
|
83
|
+
idx += 1
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def widths_hash
|
88
|
+
@object[0].each do |key, _|
|
89
|
+
klen = key.to_s.length
|
90
|
+
wid = @widths[key]
|
91
|
+
@widths[key] = klen if !wid || wid < klen
|
92
|
+
end
|
93
|
+
@object.each do |obj|
|
94
|
+
obj_width(obj)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def set_width(idx, val)
|
99
|
+
vlen = val.to_s.length
|
100
|
+
wid = @widths[idx] || 0
|
101
|
+
@widths[idx] = vlen if wid < vlen
|
102
|
+
end
|
103
|
+
|
104
|
+
def obj_width(obj)
|
105
|
+
obj.each do |key, val|
|
106
|
+
set_width(key, val)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def format_it
|
111
|
+
run
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'awesome_print'
|
3
|
+
|
4
|
+
module DLDInternet
|
5
|
+
module Thor
|
6
|
+
class Command < ::Thor
|
7
|
+
no_commands do
|
8
|
+
|
9
|
+
require 'dldinternet/thor/mixins/no_commands'
|
10
|
+
include DLDInternet::Thor::MixIns::NoCommands
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
attr_accessor :invocations
|
16
|
+
|
17
|
+
def namespace
|
18
|
+
parts = self.name.split(/::/)
|
19
|
+
parts[parts.size > 2 ? -2 : -1].downcase
|
20
|
+
end
|
21
|
+
|
22
|
+
# def command(scommand, usage, description, options = {}, &block)
|
23
|
+
# desc usage, description, options
|
24
|
+
# define_method(scommand) do |*args|
|
25
|
+
# args, opts = ::Thor::Arguments.split(args)
|
26
|
+
# block.call(args)
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
# alias_method :task, :command
|
30
|
+
|
31
|
+
def command_help(shell, command_name, invocations=[])
|
32
|
+
super(shell, command_name)
|
33
|
+
0
|
34
|
+
end
|
35
|
+
|
36
|
+
def handle_argument_error(command, error, args, arity) #:nodoc:
|
37
|
+
command_s = banner(command)
|
38
|
+
# msg = "ERROR: \"#{basename} #{command.name}\" was called with "
|
39
|
+
msg = "ERROR: \"#{command_s}\" was called with "
|
40
|
+
msg << "no arguments" if args.empty?
|
41
|
+
msg << "arguments " << args.inspect unless args.empty?
|
42
|
+
msg << "\nUsage: #{command_s}"
|
43
|
+
raise ::Thor::InvocationError, msg
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
def banner(command, namespace = nil, subcommand = false)
|
49
|
+
"#{basename} #{::DLDInternet::Thor::Command.invocations ? "#{::DLDInternet::Thor::Command.invocations.join(' ') } " : ''}#{command.formatted_usage(self, $thor_runner, subcommand)}"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
attr_accessor :formatter, :writer, :header, :format
|
55
|
+
|
56
|
+
def initialize(args = [], local_options = {}, config = {})
|
57
|
+
super(args,local_options,config)
|
58
|
+
@log_level = :warn #|| @config[:log_level].to_sym
|
59
|
+
@formatter ||= ->(hsh, tit) { default_formatter(hsh, tit) }
|
60
|
+
@writer ||= ->(str) { puts str }
|
61
|
+
@header ||= ->{}
|
62
|
+
@format ||= ->(res) { puts res.ai }
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "help [COMMAND]", "Describe available commands or one specific command"
|
66
|
+
def help(command = nil, subcommand = false)
|
67
|
+
::DLDInternet::Thor::Command.invocations = @_invocations.dup.map{ |_,v| v[0]}
|
68
|
+
# self.class.invocations[-1] = command
|
69
|
+
::DLDInternet::Thor::Command.invocations.pop if ::DLDInternet::Thor::Command.invocations[-1].eql?('help')
|
70
|
+
::DLDInternet::Thor::Command.invocations.pop if ::DLDInternet::Thor::Command.invocations[-1].eql?(command) || (!command && subcommand)
|
71
|
+
super(command, subcommand)
|
72
|
+
# if command
|
73
|
+
# if self.class.subcommands.include? command
|
74
|
+
# self.class.subcommand_classes[command].help(shell, true)
|
75
|
+
# else
|
76
|
+
# self.class.command_help(shell, command, invocations)
|
77
|
+
# end
|
78
|
+
# else
|
79
|
+
# self.class.help(shell, subcommand)
|
80
|
+
# end
|
81
|
+
0
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,234 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'awesome_print'
|
3
|
+
require 'yaml'
|
4
|
+
require 'dldinternet/formatters'
|
5
|
+
require 'hashie/mash'
|
6
|
+
require 'dldinternet/thor/version'
|
7
|
+
require 'inifile'
|
8
|
+
|
9
|
+
module DLDInternet
|
10
|
+
module Thor
|
11
|
+
LOG_LEVELS = [:trace, :debug, :info, :note, :warn, :error, :fatal, :todo]
|
12
|
+
|
13
|
+
class OptionsMash < ::Hashie::Mash ; end
|
14
|
+
|
15
|
+
module MixIns
|
16
|
+
module NoCommands
|
17
|
+
require 'dldinternet/mixlib/logging'
|
18
|
+
include DLDInternet::Mixlib::Logging
|
19
|
+
|
20
|
+
def validate_options
|
21
|
+
OptionsMash.disable_warnings
|
22
|
+
@options = OptionsMash.new(@options.to_h)
|
23
|
+
if options[:log_level]
|
24
|
+
log_level = options[:log_level].to_sym
|
25
|
+
raise "Invalid log-level: #{log_level}" unless LOG_LEVELS.include?(log_level)
|
26
|
+
options[:log_level] = log_level
|
27
|
+
end
|
28
|
+
@options[:log_level] ||= :warn
|
29
|
+
@options[:format] ||= @options[:output]
|
30
|
+
@options[:output] ||= @options[:format]
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_options
|
34
|
+
validate_options
|
35
|
+
|
36
|
+
lcs = ::Logging::ColorScheme.new( 'compiler', :levels => {
|
37
|
+
:trace => :blue,
|
38
|
+
:debug => :cyan,
|
39
|
+
:info => :green,
|
40
|
+
:note => :green,
|
41
|
+
:warn => :yellow,
|
42
|
+
:error => :red,
|
43
|
+
:fatal => :red,
|
44
|
+
:todo => :purple,
|
45
|
+
})
|
46
|
+
scheme = lcs.scheme
|
47
|
+
scheme['trace'] = "\e[38;5;33m"
|
48
|
+
scheme['fatal'] = "\e[38;5;89m"
|
49
|
+
scheme['todo'] = "\e[38;5;55m"
|
50
|
+
lcs.scheme scheme
|
51
|
+
@config = @options.dup
|
52
|
+
@config[:log_opts] = lambda{|mlll| {
|
53
|
+
:pattern => "%#{mlll}l: %m %g\n",
|
54
|
+
:date_pattern => '%Y-%m-%d %H:%M:%S',
|
55
|
+
:color_scheme => 'compiler',
|
56
|
+
:trace => (@config[:trace].nil? ? false : @config[:trace]),
|
57
|
+
# [2014-06-30 Christo] DO NOT do this ... it needs to be a FixNum!!!!
|
58
|
+
# If you want to do ::Logging.init first then fine ... go ahead :)
|
59
|
+
# :level => @config[:log_level],
|
60
|
+
}
|
61
|
+
}
|
62
|
+
@config[:log_levels] ||= LOG_LEVELS
|
63
|
+
# initLogging(@config)
|
64
|
+
@logger = getLogger(@config)
|
65
|
+
|
66
|
+
if @options[:inifile]
|
67
|
+
@options[:inifile] = File.expand_path(@options[:inifile])
|
68
|
+
unless File.exist?(@options[:inifile])
|
69
|
+
raise "#{@options[:inifile]} not found!"
|
70
|
+
end
|
71
|
+
begin
|
72
|
+
ini = ::IniFile.load(@options[:inifile])
|
73
|
+
ini['global'].each{ |key,value|
|
74
|
+
@options[key.to_s]=value
|
75
|
+
ENV[key.to_s]=value
|
76
|
+
}
|
77
|
+
def _expand(k,v,regex,rerun)
|
78
|
+
matches = v.match(regex)
|
79
|
+
if matches
|
80
|
+
var = matches[1]
|
81
|
+
if options[var]
|
82
|
+
options[k]=v.gsub(/\%\(#{var}\)/,options[var]).gsub(/\%#{var}/,options[var])
|
83
|
+
else
|
84
|
+
rerun[var] = 1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
pending = nil
|
90
|
+
rerun = {}
|
91
|
+
begin
|
92
|
+
pending = rerun
|
93
|
+
rerun = {}
|
94
|
+
options.to_hash.each{|k,v|
|
95
|
+
if v.to_s.match(/\%/)
|
96
|
+
_expand(k,v,%r'[^\\]\%\((\w+)\)', rerun)
|
97
|
+
_expand(k,v,%r'[^\\]\%(\w+)', rerun)
|
98
|
+
end
|
99
|
+
}
|
100
|
+
# Should break out the first time that we make no progress!
|
101
|
+
end while pending != rerun
|
102
|
+
rescue ::IniFile::Error => e
|
103
|
+
# noop
|
104
|
+
rescue ::Exception => e
|
105
|
+
@logger.error "#{e.class.name} #{e.message}"
|
106
|
+
raise e
|
107
|
+
end
|
108
|
+
elsif @options[:config]
|
109
|
+
@options[:config] = File.expand_path(@options[:config])
|
110
|
+
if File.exist?(@options[:config])
|
111
|
+
begin
|
112
|
+
yaml = ::YAML.load(File.read(@options[:config]))
|
113
|
+
yaml.each{ |key,value|
|
114
|
+
@options[key.to_s.gsub(%r{[-]},'_')]=value
|
115
|
+
}
|
116
|
+
rescue ::Exception => e
|
117
|
+
@logger.error "#{e.class.name} #{e.message}"
|
118
|
+
raise e
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
if options[:debug]
|
123
|
+
@logger.info "Options:\n#{options.ai}"
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
def abort!(msg)
|
129
|
+
@logger.error msg
|
130
|
+
exit -1
|
131
|
+
end
|
132
|
+
|
133
|
+
def notation
|
134
|
+
@config[:output] || :none
|
135
|
+
end
|
136
|
+
|
137
|
+
def default_formatter(obj, title)
|
138
|
+
format_helper = DLDInternet::Formatters::Basic.new(obj, notation, title)
|
139
|
+
case notation.to_sym
|
140
|
+
when :none
|
141
|
+
when :basic
|
142
|
+
when :text
|
143
|
+
# noop
|
144
|
+
when :awesome
|
145
|
+
format_helper = DLDInternet::Formatters::Awesome.new(obj, notation, title)
|
146
|
+
when :json
|
147
|
+
when :yaml
|
148
|
+
when :table
|
149
|
+
format_helper = DLDInternet::Formatters::Table.new(obj, notation, title)
|
150
|
+
else
|
151
|
+
raise DLDInternet::Formatters::Error, "Unknown format requested: #{notation}"
|
152
|
+
end
|
153
|
+
format_helper.format_it
|
154
|
+
end
|
155
|
+
|
156
|
+
def hash_it(robj)
|
157
|
+
klass = robj.class
|
158
|
+
repre = begin
|
159
|
+
klass.const_get('Representation')
|
160
|
+
rescue
|
161
|
+
false
|
162
|
+
end
|
163
|
+
if robj.nil?
|
164
|
+
robj
|
165
|
+
elsif robj.respond_to?(:to_hash)
|
166
|
+
robj.to_hash
|
167
|
+
elsif robj.respond_to?(:to_a)
|
168
|
+
robj.to_a.map { |obj| hash_it(obj) }
|
169
|
+
elsif repre
|
170
|
+
representation = repre.new(robj)
|
171
|
+
representation.to_hash
|
172
|
+
elsif robj.respond_to?(:to_h)
|
173
|
+
robj.to_h
|
174
|
+
else
|
175
|
+
robj
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def format_it(obj, title = '')
|
180
|
+
formatter.call(obj, title)
|
181
|
+
end
|
182
|
+
|
183
|
+
def write(obj)
|
184
|
+
writer.call(obj)
|
185
|
+
end
|
186
|
+
|
187
|
+
def output(obj)
|
188
|
+
unless obj.nil?
|
189
|
+
hash = obj.is_a?(Array) ? obj.map { |o| hash_it(o) } : (obj.is_a?(String) ? obj : hash_it(obj))
|
190
|
+
str = format_it(hash)
|
191
|
+
write str
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def command_pre(*args)
|
196
|
+
parse_options
|
197
|
+
@logger.info @_invocations.map{ |_,v| v[0]}.join(' ') if options[:verbose]
|
198
|
+
end
|
199
|
+
|
200
|
+
def command_out(res)
|
201
|
+
case options[:format]
|
202
|
+
when /text|none/
|
203
|
+
output header_line unless options[:header] === false
|
204
|
+
case res.class.name
|
205
|
+
when /Array/
|
206
|
+
res.each do |obj|
|
207
|
+
output format_line(obj)
|
208
|
+
end
|
209
|
+
# when /Hash|String/
|
210
|
+
else
|
211
|
+
output format_line(res)
|
212
|
+
end
|
213
|
+
else
|
214
|
+
output res
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def header_line()
|
219
|
+
@header.call()
|
220
|
+
end
|
221
|
+
|
222
|
+
def format_line(obj)
|
223
|
+
@format.call(obj)
|
224
|
+
end
|
225
|
+
|
226
|
+
def invoke_command(command, *args) #:nodoc:
|
227
|
+
::DLDInternet::Thor::Command.invocations = @_invocations.dup.map{ |_,v| v[0]}
|
228
|
+
super
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Dldinternet
|
2
|
+
module Mixlib
|
3
|
+
module Thor
|
4
|
+
VERSION = '0.2.0'
|
5
|
+
|
6
|
+
module Version # :nodoc: all
|
7
|
+
MAJOR, MINOR, RELEASE, *OTHER = VERSION.split '.'
|
8
|
+
|
9
|
+
NUMBERS = [MAJOR, MINOR, RELEASE, *OTHER].freeze
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns the version string for the library.
|
13
|
+
def self.version
|
14
|
+
VERSION
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dldinternet-mixlib-thor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christo De Lange
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.19'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.19'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: awesome_print
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: paint-shortcuts
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: dldinternet-mixlib-logging
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.5'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.5'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: inifile
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: hashie
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: command_line_reporter
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.3'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 3.3.6
|
113
|
+
type: :runtime
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '3.3'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 3.3.6
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: bundler
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.0'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '1.0'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: rake
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '10'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '10'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: rubygems-tasks
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0.2'
|
158
|
+
type: :development
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - "~>"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0.2'
|
165
|
+
description: Thor no_commands reuse
|
166
|
+
email: rubygems@dldinternet.com
|
167
|
+
executables: []
|
168
|
+
extensions: []
|
169
|
+
extra_rdoc_files: []
|
170
|
+
files:
|
171
|
+
- ".gitignore"
|
172
|
+
- ChangeLog.md
|
173
|
+
- Gemfile
|
174
|
+
- LICENSE
|
175
|
+
- LICENSE.txt
|
176
|
+
- README.md
|
177
|
+
- Rakefile
|
178
|
+
- atlassian-ide-plugin.xml
|
179
|
+
- dldinternet-mixlib-thor.gemspec
|
180
|
+
- lib/dldinternet/formatters.rb
|
181
|
+
- lib/dldinternet/formatters/awesome.rb
|
182
|
+
- lib/dldinternet/formatters/basic.rb
|
183
|
+
- lib/dldinternet/formatters/colors.rb
|
184
|
+
- lib/dldinternet/formatters/errors.rb
|
185
|
+
- lib/dldinternet/formatters/table.rb
|
186
|
+
- lib/dldinternet/thor/command.rb
|
187
|
+
- lib/dldinternet/thor/mixins/no_commands.rb
|
188
|
+
- lib/dldinternet/thor/version.rb
|
189
|
+
homepage: https://rubygems.org/gems/dldinternet-mixlib-thor
|
190
|
+
licenses:
|
191
|
+
- Apachev2
|
192
|
+
metadata: {}
|
193
|
+
post_install_message:
|
194
|
+
rdoc_options: []
|
195
|
+
require_paths:
|
196
|
+
- lib
|
197
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
requirements: []
|
208
|
+
rubyforge_project:
|
209
|
+
rubygems_version: 2.4.8
|
210
|
+
signing_key:
|
211
|
+
specification_version: 4
|
212
|
+
summary: Thor no_commands reuse
|
213
|
+
test_files: []
|