@@ -44,6 +44,7 @@ Global Commands:
44
44
--tutorial show a brief tutorial on using modman
45
45
--version display the modman script's version
46
46
[--force] overwrite existing files, ignore untrusted cert warnings
47
+ [--quiet|-q] prevent output of non-interactive commands
47
48
[--no-local] skip processing of modman.local files
48
49
[--no-clean] skip cleaning of broken symlinks
49
50
[--no-shell] skip processing @shell lines
@@ -273,6 +274,12 @@ error ()
273
274
{
274
275
echo -e " $( bold) $( red) ERROR:$( unbold) " $1
275
276
}
277
+ # ############################################################
278
+ # Usual output
279
+ log ()
280
+ {
281
+ [ $QUIET -eq 0 ] && printf " $@ " && [ $# -eq 1 ] && echo " "
282
+ }
276
283
277
284
# ############################################################
278
285
# Check for existence of a module directory and modman file
@@ -377,15 +384,15 @@ set_skipped ()
377
384
378
385
if [ " $skip " = 1 ]; then
379
386
if get_skipped $module ; then
380
- echo " Module $module already skipped."
387
+ log " Module $module already skipped."
381
388
exit 1
382
389
else
383
390
echo $module >> " $SKIP_FILE "
384
- echo " Module $module added to skip list."
391
+ log " Module $module added to skip list."
385
392
fi
386
393
else
387
394
grep -v " ^$module $" " $SKIP_FILE " > " $SKIP_FILE .tmp" ; mv " $SKIP_FILE .tmp" " $SKIP_FILE "
388
- echo " Module $module removed from skip list."
395
+ log " Module $module removed from skip list."
389
396
fi
390
397
391
398
return 0
@@ -407,7 +414,7 @@ get_abs_filename() {
407
414
408
415
remove_module_links ()
409
416
{
410
- echo " Removing links for module $module ."
417
+ log " Removing links for module $module ."
411
418
local module_dir=" $mm /$module "
412
419
for line in $( find $root -type l) ; do
413
420
if [[ $( get_abs_filename " $line " ) =~ ^" $module_dir " .* ]]; then
@@ -466,7 +473,7 @@ apply_modman_file ()
466
473
return 1
467
474
fi
468
475
469
- echo " Deploying $real "
476
+ log " Deploying $real "
470
477
if [ -z " $import_base " ]; then
471
478
import_base=${basedir%%/ }
472
479
else
@@ -477,7 +484,7 @@ apply_modman_file ()
477
484
error " Could not create import base directory: $import_base "
478
485
return 1
479
486
fi
480
- echo " Created import base directory: $import_base "
487
+ log " Created import base directory: $import_base "
481
488
fi
482
489
if ! set_basedir " $module_dir /$import_path " " $import_base " ; then
483
490
return 1
@@ -578,7 +585,7 @@ apply_path ()
578
585
if [[ " $line " != * " $real " * ]]; then
579
586
echo " $( $stat_type " $dest " ) path: $real "
580
587
fi
581
- echo " (Run with $( bold) --force$( unbold) to force removal of existing files and directories.)"
588
+ log " (Run with $( bold) --force$( unbold) to force removal of existing files and directories.)"
582
589
return 1
583
590
elif ! [ -L " $dest " ] || [ " $src " != " $( readlink " $dest " ) " ]; then
584
591
warning " Removing conflicting $( $stat_type " $dest " ) : $dest "
@@ -608,7 +615,7 @@ apply_path ()
608
615
ln -s " $src " " $dest " && success=1
609
616
fi
610
617
if [ $success -eq 1 ]; then
611
- printf " Applied: %-30s %s\n" " $target " " $real "
618
+ log " Applied: %-30s %s\n" " $target " " $real "
612
619
else
613
620
error " Unable to $verb ($dest ):\n $line "
614
621
return 1
@@ -734,6 +741,7 @@ root=$_pwd
734
741
735
742
# Check for common option overrides
736
743
FORCE=0 # --force option off by default
744
+ QUIET=0 # --quiet option off by default
737
745
NOLOCAL=0 # --no-local option off by default
738
746
NOCLEAN=0 # --no-clean off by default
739
747
NOSHELL=0 # --no-shell option off by default
@@ -743,6 +751,7 @@ basedir=''
743
751
while true ; do
744
752
case " $1 " in
745
753
--force) FORCE=1; shift ;;
754
+ --quiet|-q) QUIET=1; shift ;;
746
755
--no-local) NOLOCAL=1; shift ;;
747
756
--no-clean) NOCLEAN=1; shift ;;
748
757
--no-shell) NOSHELL=1; shift ;;
@@ -859,12 +868,12 @@ elif [ "$action" = "deploy-all" ]; then
859
868
for module in $( ls -1 " $mm " ) ; do
860
869
test -d " $mm /$module " && require_wc " $module " || continue ;
861
870
if get_skipped " $module " ; then
862
- echo " Skipping module $module due to .modman-skip file."
871
+ log " Skipping module $module due to .modman-skip file."
863
872
continue
864
873
fi
865
- echo " Deploying $module to $root "
874
+ log " Deploying $module to $root "
866
875
if apply_modman_file " $mm /$module /modman" ; then
867
- echo -e " Deployment of '$module ' complete.\n"
876
+ log " Deployment of '$module ' complete.\n"
868
877
if [ $NOLOCAL -eq 0 -a -r " $mm /$module /modman.local" ]; then
869
878
apply_modman_file " $mm /$module /modman.local" && echo " Applied local modman file for $module "
870
879
fi
@@ -873,7 +882,7 @@ elif [ "$action" = "deploy-all" ]; then
873
882
errors=$(( errors+ 1 ))
874
883
fi
875
884
done
876
- echo " Deployed all modules with $errors errors."
885
+ log " Deployed all modules with $errors errors."
877
886
if [ $errors -gt 0 ]; then
878
887
exit 1
879
888
else
@@ -896,7 +905,7 @@ elif [ "$action" = "update-all" ]; then
896
905
if [ -e .git ]; then
897
906
if [ -d .git ]; then
898
907
if [ " $( git remote) " != " " ]; then
899
- echo " Fetching changes for $module "
908
+ log " Fetching changes for $module "
900
909
success=0
901
910
if [ $FORCE -eq 1 ]; then
902
911
if git status -s | grep -vq ' ??' ; then
@@ -910,13 +919,13 @@ elif [ "$action" = "update-all" ]; then
910
919
fi
911
920
fi
912
921
else
913
- echo " Git submodule detected. Determining state..."
922
+ log " Git submodule detected. Determining state..."
914
923
if [ $( git rev-parse --symbolic-full-name --abbrev-ref HEAD) = " HEAD" ]; then
915
- echo " In detached state, checking out main branch..."
924
+ log " In detached state, checking out main branch..."
916
925
branch=$( git ls-remote --heads origin | grep $( git rev-parse HEAD) | cut -d / -f 3)
917
926
git checkout $branch
918
927
fi
919
- echo " Fetching changes for $module "
928
+ log " Fetching changes for $module "
920
929
success=0
921
930
if [ $FORCE -eq 1 ]; then
922
931
if git status -s | grep -vq ' ??' ; then
@@ -944,15 +953,15 @@ elif [ "$action" = "update-all" ]; then
944
953
cd " $mm /$module "
945
954
success=0
946
955
if [ -d .svn ]; then
947
- echo " Updating $module "
956
+ log " Updating $module "
948
957
if [ $FORCE -eq 1 ]; then
949
958
svn update --force --non-interactive --trust-server-cert && success=1
950
959
else
951
960
svn update && success=1
952
961
fi
953
962
elif [ -e .git ] && [ " $( git remote) " != " " ]; then
954
963
tracking_branch=$( get_tracking_branch)
955
- echo " Updating $module "
964
+ log " Updating $module "
956
965
if [ -z $tracking_branch ]; then
957
966
echo " Could not resolve remote tracking branch, code will not be updated."
958
967
elif [ $FORCE -eq 1 ]; then
@@ -961,12 +970,12 @@ elif [ "$action" = "update-all" ]; then
961
970
git merge $tracking_branch && git submodule update --init --recursive && success=1
962
971
fi
963
972
elif [ -d .hg ]; then
964
- echo " Updating $module "
973
+ log " Updating $module "
965
974
hg pull && hg update && success=1
966
975
else
967
976
success=1
968
977
fi
969
- echo
978
+ log " " ; # Forced new line, respect --quiet
970
979
if [ $success -ne 1 ]; then
971
980
error " Error occurred while updating $module \n"
972
981
update_errors=$(( update_errors+ 1 ))
@@ -977,7 +986,7 @@ elif [ "$action" = "update-all" ]; then
977
986
for module in $( ls -1 " $mm " ) ; do
978
987
test -d " $mm /$module " && require_wc " $module " || continue ;
979
988
if apply_modman_file " $mm /$module /modman" ; then
980
- echo -e " Deployment of '$module ' complete.\n "
989
+ log " Deployment of '$module ' complete."
981
990
if [ $NOLOCAL -eq 0 -a -r " $mm /$module /modman.local" ]; then
982
991
apply_modman_file " $mm /$module /modman.local" && echo " Applied local modman file for $module "
983
992
fi
@@ -986,31 +995,34 @@ elif [ "$action" = "update-all" ]; then
986
995
deploy_errors=$(( deploy_errors+ 1 ))
987
996
fi
988
997
done
989
- echo " Updated all modules with $update_errors update errors and $deploy_errors deploy errors."
998
+ log " Updated all modules with $update_errors update errors and $deploy_errors deploy errors."
990
999
exit 0
991
1000
992
1001
# ##########################
993
1002
# Handle "repair" command
994
1003
elif [ " $action " = " repair" ]; then
995
- echo " Repairing links, do not interrupt."
1004
+ log " Repairing links, do not interrupt."
996
1005
mv " $mm " " $mm -repairing" || { error " Could not temporarily rename .modman directory." ; exit 1; }
997
1006
remove_dead_links
998
1007
mv " $mm -repairing" " $mm " || { error " Could not restore .modman directory." ; exit 1; }
999
1008
for module in $( ls -1 " $mm " ) ; do
1000
1009
test -d " $mm /$module " && require_wc " $module " || continue ;
1010
+ log " Deploying $module to $root "
1001
1011
remove_basedirs " $module " &&
1002
1012
apply_modman_file " $mm /$module /modman" &&
1003
- echo -e " Repaired $module .\n "
1013
+ log " Repaired $module ."
1004
1014
if [ $NOLOCAL -eq 0 -a -r " $mm /$module /modman.local" ]; then
1005
- apply_modman_file " $mm /$module /modman.local" && echo " Applied local modman file for $module "
1015
+ if apply_modman_file " $mm /$module /modman.local" ; then
1016
+ log " Applied local modman file for $module "
1017
+ fi
1006
1018
fi
1007
1019
done
1008
1020
exit 0
1009
1021
1010
1022
# ##########################
1011
1023
# Handle "clean" command
1012
1024
elif [ " $action " = " clean" ]; then
1013
- echo " Cleaning broken links."
1025
+ log " Cleaning broken links."
1014
1026
NOCLEAN=0
1015
1027
remove_dead_links
1016
1028
exit 0
0 commit comments