11use std:: fs;
2- use std:: process:: { exit , Command , ExitStatus } ;
2+ use std:: process:: { Command , ExitStatus , exit } ;
33
4- use anyhow:: { anyhow , bail , Context , Result } ;
4+ use anyhow:: { Context , Result , anyhow , bail } ;
55use clap:: ArgMatches ;
66use configparser:: ini:: Ini ;
77use directories:: UserDirs ;
@@ -13,21 +13,22 @@ use crate::utils::{output_failure, output_success};
1313pub fn commit_changes ( conf : & Config , args : & ArgMatches , inputs : & Inputs ) -> Result < ( ) > {
1414 let git_program = "git" ;
1515 println ! ( ) ;
16- if args. get_flag ( "all" ) {
17- let status = Command :: new ( git_program)
18- . args ( [ "add" , "--verbose" , "." ] )
19- . status ( )
20- . context ( "Failed to stage all changes" ) ?;
21- check_status ( status, "stage all changes" ) ;
22- output_success ( "Staged all changes\n " ) ;
23- }
2416
17+ let all_flag = args. get_flag ( "all" ) ;
2518 let status = Command :: new ( git_program)
26- . args ( [ "commit" , "-m" , & message ( conf, inputs) ?] )
19+ . args ( [
20+ "commit" ,
21+ if all_flag { "-am" } else { "-m" } ,
22+ & message ( conf, inputs) ?,
23+ ] )
2724 . status ( )
2825 . context ( "Failed to commit changes" ) ?;
2926 check_status ( status, "commit changes" ) ;
30- output_success ( "Committed changes" ) ;
27+ output_success ( if all_flag {
28+ "Committed all changes"
29+ } else {
30+ "Committed changes"
31+ } ) ;
3132
3233 if args. get_flag ( "push" ) {
3334 println ! ( ) ;
0 commit comments