15
15
16
16
@click .command (context_settings = CONTEXT_SETTINGS ,
17
17
short_help = 'Creates a new Python project' )
18
- @click .argument ('name' )
18
+ @click .argument ('name' , nargs = - 1 , default = None )
19
19
@click .option ('-ne' , '--no-env' , is_flag = True ,
20
20
help = (
21
21
'Disables the creation of a dedicated virtual env.'
44
44
'within. Also, a `__main__.py` is created so it can be '
45
45
'invoked via `python -m pkg_name`.'
46
46
))
47
- @click .option ('-l' , '--licenses' ,
48
- help = 'Comma-separated list of licenses to use.' )
49
- def new (name , no_env , pyname , pypath , env_name , basic , cli , licenses ):
47
+ def new (name , no_env , pyname , pypath , env_name , basic , cli ):
50
48
"""Creates a new Python project.
51
49
52
50
Values from your config file such as `name` and `pyversions` will be used
@@ -91,18 +89,27 @@ def new(name, no_env, pyname, pypath, env_name, basic, cli, licenses):
91
89
if basic :
92
90
settings ['basic' ] = True
93
91
94
- if licenses :
95
- settings ['licenses' ] = licenses .split (',' )
96
-
97
92
settings ['cli' ] = cli
98
93
99
94
origin = os .getcwd ()
100
- d = os .path .join (origin , name )
95
+ if name :
96
+ settings ['package_name' ] = name [0 ]
97
+ else :
98
+ settings ['package_name' ] = click .prompt ('project name' )
99
+
100
+ d = os .path .join (origin , settings ['package_name' ])
101
101
102
102
if os .path .exists (d ):
103
103
echo_failure ('Directory `{}` already exists.' .format (d ))
104
104
sys .exit (1 )
105
105
106
+ settings ['version' ] = click .prompt ('version' , default = '1.0.0' )
107
+ settings ['description' ] = click .prompt ('description' , default = '' )
108
+ settings ['author' ] = click .prompt ('author' , default = '' )
109
+ settings ['email' ] = click .prompt ('author_email' , default = '' )
110
+ licenses = click .prompt ('license' , default = 'mit' )
111
+ settings ['licenses' ] = map (str .strip , licenses .split (',' ))
112
+
106
113
venvs = env_name .split ('/' ) if env_name else []
107
114
if (venvs or not no_env ) and pyname :
108
115
try :
@@ -118,8 +125,8 @@ def new(name, no_env, pyname, pypath, env_name, basic, cli, licenses):
118
125
119
126
os .makedirs (d )
120
127
with chdir (d , cwd = origin ):
121
- create_package (d , name , settings )
122
- echo_success ('Created project `{}`' .format (name ))
128
+ create_package (d , settings )
129
+ echo_success ('Created project `{}`' .format (settings [ 'package_name' ] ))
123
130
124
131
if not no_env :
125
132
venv_dir = os .path .join (d , 'venv' )
0 commit comments