... | ... |
@@ -4,6 +4,10 @@ All notable changes to miniver will be documented in this file. |
4 | 4 |
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
5 | 5 |
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
6 | 6 |
|
7 |
+## [Unreleased] |
|
8 |
+### Changed |
|
9 |
+- Replace tool "install-miniver" with a tool "miniver" with a command "install" |
|
10 |
+ |
|
7 | 11 |
## [0.6.0] - 2019-02-17 |
8 | 12 |
### Fixed |
9 | 13 |
- Typos in generated files (comments only) |
... | ... |
@@ -35,7 +35,7 @@ works with Python 2](https://github.com/cmarquardt/miniver2) |
35 | 35 |
## Usage |
36 | 36 |
The simplest way to use Miniver is to run the following in your project root: |
37 | 37 |
``` |
38 |
-curl https://raw.githubusercontent.com/jbweston/miniver/master/install-miniver | python - <your_package_directory> |
|
38 |
+curl https://raw.githubusercontent.com/jbweston/miniver/master/bin/miniver | python - install <your_package_directory> |
|
39 | 39 |
``` |
40 | 40 |
This will grab the latest files from GitHub and set up Miniver for your project. |
41 | 41 |
|
... | ... |
@@ -52,10 +52,10 @@ curl https://raw.githubusercontent.com/jbweston/miniver/master/unannotated-tags. |
52 | 52 |
``` |
53 | 53 |
|
54 | 54 |
### I don't want to type that URL every time I use this |
55 |
-You can `pip install miniver`, which will give you the `install-miniver` script. |
|
55 |
+You can `pip install miniver`, which will give you the `miniver` command. |
|
56 | 56 |
Then you can simply run the following from your project root to use Miniver: |
57 | 57 |
``` |
58 |
-install-miniver <your_package_directory> |
|
58 |
+miniver install <your_package_directory> |
|
59 | 59 |
``` |
60 | 60 |
|
61 | 61 |
### Can I use this without executing random code from the internet? |
62 | 62 |
similarity index 86% |
63 | 63 |
rename from install-miniver |
64 | 64 |
rename to bin/miniver |
... | ... |
@@ -132,19 +132,24 @@ def extract_miniver_from_local(): |
132 | 132 |
] |
133 | 133 |
|
134 | 134 |
|
135 |
-def get_args(): |
|
136 |
- parser = argparse.ArgumentParser( |
|
137 |
- description="Install 'miniver' into the current Python package" |
|
138 |
- ) |
|
135 |
+def get_parser(): |
|
136 |
+ parser = argparse.ArgumentParser(description="Interact with miniver") |
|
139 | 137 |
parser.add_argument("-v", "--version", action="version", version=_miniver_version) |
140 |
- parser.add_argument( |
|
138 |
+ # TODO: when we can depend on Python 3.7 make this "add_subparsers(required=True)" |
|
139 |
+ subparsers = parser.add_subparsers() |
|
140 |
+ # 'install' command |
|
141 |
+ install_parser = subparsers.add_parser( |
|
142 |
+ "install", help="Install miniver into the current Python package" |
|
143 |
+ ) |
|
144 |
+ install_parser.add_argument( |
|
141 | 145 |
"package_directory", help="Directory to install 'miniver' into." |
142 | 146 |
) |
143 |
- return parser.parse_args().package_directory |
|
147 |
+ install_parser.set_defaults(dispatch=install) |
|
148 |
+ return parser |
|
144 | 149 |
|
145 | 150 |
|
146 |
-def main(): |
|
147 |
- package_dir = get_args() |
|
151 |
+def install(args): |
|
152 |
+ package_dir = args.package_directory |
|
148 | 153 |
if not os.path.isdir(package_dir): |
149 | 154 |
_fail("Directory '{}' does not exist".format(package_dir)) |
150 | 155 |
if package_dir != os.path.relpath(package_dir): |
... | ... |
@@ -186,5 +191,16 @@ def main(): |
186 | 191 |
print("\n".join((msg, _setup_template)).format(package_dir=package_dir)) |
187 | 192 |
|
188 | 193 |
|
194 |
+def main(): |
|
195 |
+ parser = get_parser() |
|
196 |
+ args = parser.parse_args() |
|
197 |
+ # TODO: remove this check when we can rely on Python 3.7 and |
|
198 |
+ # can make subparsers required. |
|
199 |
+ if "dispatch" in args: |
|
200 |
+ args.dispatch(args) |
|
201 |
+ else: |
|
202 |
+ parser.parse_args(['-h']) |
|
203 |
+ |
|
204 |
+ |
|
189 | 205 |
if __name__ == "__main__": |
190 | 206 |
main() |