File tree 2 files changed +22
-1
lines changed 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,16 @@ pub fn cli() -> App {
11
11
12
12
pub fn exec ( config : & mut Config , args : & ArgMatches ) -> CliResult {
13
13
let opts = args. new_options ( config) ?;
14
+
14
15
ops:: new ( & opts, config) ?;
15
16
let path = args. value_of ( "path" ) . unwrap ( ) ;
17
+ let project_name = if let Some ( name) = args. value_of ( "name" ) {
18
+ name
19
+ } else {
20
+ path
21
+ } ;
16
22
config
17
23
. shell ( )
18
- . status ( "Created" , format ! ( "{} `{}` project" , opts. kind, path ) ) ?;
24
+ . status ( "Created" , format ! ( "{} `{}` project" , opts. kind, project_name ) ) ?;
19
25
Ok ( ( ) )
20
26
}
Original file line number Diff line number Diff line change @@ -545,3 +545,18 @@ fn explicit_invalid_name_not_suggested() {
545
545
) ,
546
546
) ;
547
547
}
548
+
549
+ #[ test]
550
+ fn explicit_project_name ( ) {
551
+ assert_that (
552
+ cargo_process ( "new" )
553
+ . arg ( "--lib" )
554
+ . arg ( "foo" )
555
+ . arg ( "--name" )
556
+ . arg ( "bar" )
557
+ . env ( "USER" , "foo" ) ,
558
+ execs ( )
559
+ . with_status ( 0 )
560
+ . with_stderr ( "[CREATED] library `bar` project" ) ,
561
+ ) ;
562
+ }
You can’t perform that action at this time.
0 commit comments