14
14
15
15
@click .command (context_settings = CONTEXT_SETTINGS ,
16
16
short_help = 'Creates a new Python project in the current directory' )
17
- @click .argument ('name' )
18
17
@click .option ('-ne' , '--no-env' , is_flag = True ,
19
18
help = (
20
19
'Disables the creation of a dedicated virtual env.'
43
42
'within. Also, a `__main__.py` is created so it can be '
44
43
'invoked via `python -m pkg_name`.'
45
44
))
46
- @click .option ('-l' , '--licenses' ,
47
- help = 'Comma-separated list of licenses to use.' )
48
- def init (name , no_env , pyname , pypath , env_name , basic , cli , licenses ):
45
+ def init (no_env , pyname , pypath , env_name , basic , cli ):
49
46
"""Creates a new Python project in the current directory.
50
47
51
48
Values from your config file such as `name` and `pyversions` will be used
@@ -87,17 +84,23 @@ def init(name, no_env, pyname, pypath, env_name, basic, cli, licenses):
87
84
'The default project structure will be used.'
88
85
)
89
86
87
+ cwd = os .getcwd ()
88
+ pname = os .path .split (cwd )[- 1 ]
89
+ settings ['package_name' ] = click .prompt ('project name' , default = pname )
90
+ settings ['version' ] = click .prompt ('version' , default = '1.0.0' )
91
+ settings ['description' ] = click .prompt ('description' , default = '' )
92
+ settings ['author' ] = click .prompt ('author' , default = '' )
93
+ settings ['email' ] = click .prompt ('author_email' , default = '' )
94
+ licenses = click .prompt ('license' , default = 'mit' )
95
+ settings ['licenses' ] = map (str .strip , licenses .split (',' ))
96
+
90
97
if basic :
91
98
settings ['basic' ] = True
92
99
93
- if licenses :
94
- settings ['licenses' ] = licenses .split (',' )
95
-
96
100
settings ['cli' ] = cli
97
101
98
- d = os .getcwd ()
99
- create_package (d , name , settings )
100
- echo_success ('Created project `{}` here' .format (name ))
102
+ create_package (cwd , settings )
103
+ echo_success ('Created project `{}` here' .format (settings ['package_name' ]))
101
104
102
105
venvs = env_name .split ('/' ) if env_name else []
103
106
if (venvs or not no_env ) and pyname :
@@ -113,7 +116,7 @@ def init(name, no_env, pyname, pypath, env_name, basic, cli, licenses):
113
116
sys .exit (1 )
114
117
115
118
if not no_env :
116
- venv_dir = os .path .join (d , 'venv' )
119
+ venv_dir = os .path .join (cwd , 'venv' )
117
120
echo_waiting ('Creating its own virtual env... ' , nl = False )
118
121
create_venv (venv_dir , pypath = pypath )
119
122
echo_success ('complete!' )
0 commit comments