@@ -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] 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
@@ -271,6 +272,12 @@ error ()
271
272
{
272
273
echo -e " $( bold) $( red) ERROR:$( unbold) " $1
273
274
}
275
+ # ############################################################
276
+ # Usual output
277
+ log ()
278
+ {
279
+ [ $QUIET -eq 0 ] && printf " $@ " && [ $# -eq 1 ] && echo " "
280
+ }
274
281
275
282
# ############################################################
276
283
# Check for existence of a module directory and modman file
@@ -375,15 +382,15 @@ set_skipped ()
375
382
376
383
if [ " $skip " = 1 ]; then
377
384
if get_skipped $module ; then
378
- echo " Module $module already skipped."
385
+ log " Module $module already skipped."
379
386
exit 1
380
387
else
381
388
echo $module >> " $SKIP_FILE "
382
- echo " Module $module added to skip list."
389
+ log " Module $module added to skip list."
383
390
fi
384
391
else
385
392
grep -v " ^$module $" " $SKIP_FILE " > " $SKIP_FILE .tmp" ; mv " $SKIP_FILE .tmp" " $SKIP_FILE "
386
- echo " Module $module removed from skip list."
393
+ log " Module $module removed from skip list."
387
394
fi
388
395
389
396
return 0
@@ -397,7 +404,7 @@ get_abs_filename() {
397
404
398
405
remove_module_links ()
399
406
{
400
- echo " Removing links for module $module ."
407
+ log " Removing links for module $module ."
401
408
local module_dir=" $mm /$module "
402
409
for line in $( find $root -type l) ; do
403
410
if [[ $( get_abs_filename " $line " ) =~ ^" $module_dir " .* ]]; then
@@ -466,7 +473,7 @@ apply_modman_file ()
466
473
error " Could not create import base directory: $import_base "
467
474
return 1
468
475
fi
469
- echo " Created import base directory: $import_base "
476
+ log " Created import base directory: $import_base "
470
477
fi
471
478
if ! set_basedir " $module_dir /$import_path " " $import_base " ; then
472
479
return 1
@@ -567,7 +574,7 @@ apply_path ()
567
574
if [[ " $line " != * " $real " * ]]; then
568
575
echo " $( $stat_type " $dest " ) path: $real "
569
576
fi
570
- echo " (Run with $( bold) --force$( unbold) to force removal of existing files and directories.)"
577
+ log " (Run with $( bold) --force$( unbold) to force removal of existing files and directories.)"
571
578
return 1
572
579
elif ! [ -L " $dest " ] || [ " $src " != " $( readlink " $dest " ) " ]; then
573
580
warning " Removing conflicting $( $stat_type " $dest " ) : $dest "
@@ -597,7 +604,7 @@ apply_path ()
597
604
ln -s " $src " " $dest " && success=1
598
605
fi
599
606
if [ $success -eq 1 ]; then
600
- printf " Applied: %-30s %s\n" " $target " " $real "
607
+ log " Applied: %-30s %s\n" " $target " " $real "
601
608
else
602
609
error " Unable to $verb ($dest ):\n $line "
603
610
return 1
739
746
740
747
# Check for common option overrides
741
748
FORCE=0 # --force option off by default
749
+ QUIET=0 # --quiet option off by default
742
750
NOLOCAL=0 # --no-local option off by default
743
751
NOCLEAN=0 # --no-clean off by default
744
752
NOSHELL=0 # --no-shell option off by default
@@ -747,6 +755,7 @@ basedir=''
747
755
while true ; do
748
756
case " $1 " in
749
757
--force) FORCE=1; shift ;;
758
+ --quiet|-q) QUIET=1; shift ;;
750
759
--no-local) NOLOCAL=1; shift ;;
751
760
--no-clean) NOCLEAN=1; shift ;;
752
761
--no-shell) NOSHELL=1; shift ;;
@@ -836,12 +845,12 @@ elif [ "$action" = "deploy-all" ]; then
836
845
for module in $( ls -1 " $mm " ) ; do
837
846
test -d " $mm /$module " && require_wc " $module " || continue ;
838
847
if get_skipped " $module " ; then
839
- echo " Skipping module $module due to .modman-skip file."
848
+ log " Skipping module $module due to .modman-skip file."
840
849
continue
841
850
fi
842
- echo " Deploying $module to $root "
851
+ log " Deploying $module to $root "
843
852
if apply_modman_file " $mm /$module /modman" ; then
844
- echo -e " Deployment of '$module ' complete.\n"
853
+ log " Deployment of '$module ' complete.\n"
845
854
if [ $NOLOCAL -eq 0 -a -r " $mm /$module /modman.local" ]; then
846
855
apply_modman_file " $mm /$module /modman.local" && echo " Applied local modman file for $module "
847
856
fi
@@ -850,7 +859,7 @@ elif [ "$action" = "deploy-all" ]; then
850
859
errors=$(( errors+ 1 ))
851
860
fi
852
861
done
853
- echo " Deployed all modules with $errors errors."
862
+ log " Deployed all modules with $errors errors."
854
863
exit 0
855
864
856
865
# ##############################
@@ -867,7 +876,7 @@ elif [ "$action" = "update-all" ]; then
867
876
cd " $mm /$module "
868
877
success=1
869
878
if [ -d .git ] && [ " $( git remote) " != " " ]; then
870
- echo " Fetching changes for $module "
879
+ log " Fetching changes for $module "
871
880
success=0
872
881
if [ $FORCE -eq 1 ]; then
873
882
if git status -s | grep -vq ' ??' ; then
@@ -894,15 +903,15 @@ elif [ "$action" = "update-all" ]; then
894
903
cd " $mm /$module "
895
904
success=0
896
905
if [ -d .svn ]; then
897
- echo " Updating $module "
906
+ log " Updating $module "
898
907
if [ $FORCE -eq 1 ]; then
899
908
svn update --force --non-interactive --trust-server-cert && success=1
900
909
else
901
910
svn update && success=1
902
911
fi
903
912
elif [ -d .git ] && [ " $( git remote) " != " " ]; then
904
913
tracking_branch=$( get_tracking_branch)
905
- echo " Updating $module "
914
+ log " Updating $module "
906
915
if [ -z $tracking_branch ]; then
907
916
echo " Could not resolve remote tracking branch, code will not be updated."
908
917
elif [ $FORCE -eq 1 ]; then
@@ -911,12 +920,12 @@ elif [ "$action" = "update-all" ]; then
911
920
git merge $tracking_branch && git submodule update --init --recursive && success=1
912
921
fi
913
922
elif [ -d .hg ]; then
914
- echo " Updating $module "
923
+ log " Updating $module "
915
924
hg pull && hg update && success=1
916
925
else
917
926
success=1
918
927
fi
919
- echo
928
+ log " " ; # Forced new line, respect --quiet
920
929
if [ $success -ne 1 ]; then
921
930
error " Error occurred while updating $module \n"
922
931
update_errors=$(( update_errors+ 1 ))
@@ -927,7 +936,7 @@ elif [ "$action" = "update-all" ]; then
927
936
for module in $( ls -1 " $mm " ) ; do
928
937
test -d " $mm /$module " && require_wc " $module " || continue ;
929
938
if apply_modman_file " $mm /$module /modman" ; then
930
- echo -e " Deployment of '$module ' complete.\n "
939
+ log " Deployment of '$module ' complete."
931
940
if [ $NOLOCAL -eq 0 -a -r " $mm /$module /modman.local" ]; then
932
941
apply_modman_file " $mm /$module /modman.local" && echo " Applied local modman file for $module "
933
942
fi
@@ -936,31 +945,34 @@ elif [ "$action" = "update-all" ]; then
936
945
deploy_errors=$(( deploy_errors+ 1 ))
937
946
fi
938
947
done
939
- echo " Updated all modules with $update_errors update errors and $deploy_errors deploy errors."
948
+ log " Updated all modules with $update_errors update errors and $deploy_errors deploy errors."
940
949
exit 0
941
950
942
951
# ##########################
943
952
# Handle "repair" command
944
953
elif [ " $action " = " repair" ]; then
945
- echo " Repairing links, do not interrupt."
954
+ log " Repairing links, do not interrupt."
946
955
mv " $mm " " $mm -repairing" || { error " Could not temporarily rename .modman directory." ; exit 1; }
947
956
remove_dead_links
948
957
mv " $mm -repairing" " $mm " || { error " Could not restore .modman directory." ; exit 1; }
949
958
for module in $( ls -1 " $mm " ) ; do
950
959
test -d " $mm /$module " && require_wc " $module " || continue ;
960
+ log " Deploying $module to $root "
951
961
remove_basedirs " $module " &&
952
962
apply_modman_file " $mm /$module /modman" &&
953
- echo -e " Repaired $module .\n "
963
+ log " Repaired $module ."
954
964
if [ $NOLOCAL -eq 0 -a -r " $mm /$module /modman.local" ]; then
955
- apply_modman_file " $mm /$module /modman.local" && echo " Applied local modman file for $module "
965
+ if apply_modman_file " $mm /$module /modman.local" ; then
966
+ log " Applied local modman file for $module "
967
+ fi
956
968
fi
957
969
done
958
970
exit 0
959
971
960
972
# ##########################
961
973
# Handle "clean" command
962
974
elif [ " $action " = " clean" ]; then
963
- echo " Cleaning broken links."
975
+ log " Cleaning broken links."
964
976
NOCLEAN=0
965
977
remove_dead_links
966
978
exit 0
0 commit comments