Skip to content

Commit 515b197

Browse files
committed
- Add --force and --verbose to 'rush undo' and 'rush snatch'
1 parent d9c0fc6 commit 515b197

25 files changed

+177
-94
lines changed

rush

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ rush_usage() {
7878

7979
# :environment_variable.usage
8080
echo " RUSH_CONFIG"
81-
printf " Location of the rush config file.\n Default: ~/rush.ini\n"
81+
printf " Location of the rush config file\n Default: ~/rush.ini\n"
8282
echo
8383

8484
fi
@@ -224,40 +224,40 @@ rush_clone_usage() {
224224
# :command.usage_flags
225225
# :flag.usage
226226
echo " --ssh, -s"
227-
printf " Clone using SSH instead of HTTPS.\n"
227+
printf " Clone using SSH instead of HTTPS\n"
228228
echo
229229

230230
# :flag.usage
231231
echo " --default, -d"
232-
printf " Set this as the default repository (same as '--name default').\n"
232+
printf " Set this as the default repository (same as '--name default')\n"
233233
echo
234234

235235
# :flag.usage
236236
echo " --name, -n NAME"
237-
printf " Name to use in the config file.\n Default: GitHub user\n"
237+
printf " Name to use in the config file\n Default: GitHub user\n"
238238
echo
239239

240240
# :flag.usage
241241
echo " --shallow, -w"
242-
printf " Perform a shallow clone, instead of the default full clone.\n"
242+
printf " Perform a shallow clone, instead of the default full clone\n"
243243
echo
244244

245245
# :flag.usage
246246
echo " --ignore, -i"
247-
printf " Ignore (do not clone) if a repository with this name exists.\n"
247+
printf " Ignore (do not clone) if a repository with this name exists\n"
248248
echo
249249

250250
# :command.usage_args
251251
printf "Arguments:\n"
252252

253253
# :argument.usage
254254
echo " GITHUB_USER"
255-
printf " Github user.\n This user is expected to have a repository named 'rush-repo'.\n If you need to use a different name, use the 'user/repo' syntax.\n"
255+
printf " Github user\n This user is expected to have a repository named 'rush-repo'.\n If you need to use a different name, use the 'user/repo' syntax.\n"
256256
echo
257257

258258
# :argument.usage
259259
echo " PATH"
260-
printf " Local path to clone the repository to.\n Default: ~/rush-repos/<github_user>/<github_repo>\n"
260+
printf " Local path to clone the repository into\n Default: ~/rush-repos/<github_user>/<github_repo>\n"
261261
echo
262262

263263
# :command.usage_examples
@@ -348,15 +348,15 @@ rush_push_usage() {
348348

349349
# :flag.usage
350350
echo " --message, -m TEXT"
351-
printf " Commit message.\n Default: automatic commit\n"
351+
printf " Commit message\n Default: automatic commit\n"
352352
echo
353353

354354
# :command.usage_args
355355
printf "Arguments:\n"
356356

357357
# :argument.usage
358358
echo " REPO"
359-
printf " Repository name.\n Default: default\n"
359+
printf " Repository name\n Default: default\n"
360360
echo
361361

362362
fi
@@ -434,7 +434,7 @@ rush_default_usage() {
434434

435435
# :argument.usage
436436
echo " REPO"
437-
printf " Repository name.\n"
437+
printf " Repository name\n"
438438
echo
439439

440440
# :command.usage_examples
@@ -480,12 +480,12 @@ rush_get_usage() {
480480
# :command.usage_flags
481481
# :flag.usage
482482
echo " --clone, -c"
483-
printf " Clone the repository if it is not found locally.\n This flag will look for a GitHub user with the same name as the\n repository, and attempt to clone their rush-repo repository.\n"
483+
printf " Clone the repository if it is not found locally\n This flag will look for a GitHub user with the same name as the\n repository, and attempt to clone their rush-repo repository.\n"
484484
echo
485485

486486
# :flag.usage
487487
echo " --force, -f"
488-
printf " Force installation.\n This may mean different things in different packages.\n"
488+
printf " Force installation\n This may mean different things in different packages.\n"
489489
echo
490490

491491
# :flag.usage
@@ -498,7 +498,7 @@ rush_get_usage() {
498498

499499
# :argument.usage
500500
echo " PACKAGE"
501-
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
501+
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
502502
echo
503503

504504
# :command.usage_examples
@@ -530,7 +530,7 @@ rush_undo_usage() {
530530
echo
531531

532532
printf "Usage:\n"
533-
printf " rush undo PACKAGE\n"
533+
printf " rush undo PACKAGE [OPTIONS]\n"
534534
printf " rush undo --help | -h\n"
535535
echo
536536

@@ -543,12 +543,18 @@ rush_undo_usage() {
543543
printf " Show this help\n"
544544
echo
545545

546+
# :command.usage_flags
547+
# :flag.usage
548+
echo " --verbose, -v"
549+
printf " Show additional details if possible\n"
550+
echo
551+
546552
# :command.usage_args
547553
printf "Arguments:\n"
548554

549555
# :argument.usage
550556
echo " PACKAGE"
551-
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
557+
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
552558
echo
553559

554560
# :command.usage_examples
@@ -576,7 +582,7 @@ rush_snatch_usage() {
576582
fi
577583

578584
printf "Usage:\n"
579-
printf " rush snatch GITHUB_USER PACKAGE\n"
585+
printf " rush snatch GITHUB_USER PACKAGE [OPTIONS]\n"
580586
printf " rush snatch --help | -h\n"
581587
echo
582588

@@ -589,12 +595,23 @@ rush_snatch_usage() {
589595
printf " Show this help\n"
590596
echo
591597

598+
# :command.usage_flags
599+
# :flag.usage
600+
echo " --force, -f"
601+
printf " Force installation\n This may mean different things in different packages.\n"
602+
echo
603+
604+
# :flag.usage
605+
echo " --verbose, -v"
606+
printf " Show additional details if possible.\n"
607+
echo
608+
592609
# :command.usage_args
593610
printf "Arguments:\n"
594611

595612
# :argument.usage
596613
echo " GITHUB_USER"
597-
printf " Github user.\n This user is expected to have a repository named 'rush-repo'.\n If you need to use a different name, use the 'user/repo' syntax.\n"
614+
printf " Github user\n This user is expected to have a repository named 'rush-repo'.\n If you need to use a different name, use the 'user/repo' syntax.\n"
598615
echo
599616

600617
# :argument.usage
@@ -640,20 +657,20 @@ rush_copy_usage() {
640657
# :command.usage_flags
641658
# :flag.usage
642659
echo " --force, -f"
643-
printf " Copy the package even if it already exists in the target repository.\n"
660+
printf " Copy the package even if it already exists in the target repository\n"
644661
echo
645662

646663
# :command.usage_args
647664
printf "Arguments:\n"
648665

649666
# :argument.usage
650667
echo " SOURCE_PACKAGE"
651-
printf " Source package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
668+
printf " Source package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
652669
echo
653670

654671
# :argument.usage
655672
echo " TARGET_PACKAGE"
656-
printf " Target package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n If left empty, the package will be copied with the same name to the\n default repository.\n"
673+
printf " Target package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n If left empty, the package will be copied with the same name to the\n default repository.\n"
657674
echo
658675

659676
# :command.usage_examples
@@ -703,7 +720,7 @@ rush_info_usage() {
703720

704721
# :argument.usage
705722
echo " PACKAGE"
706-
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
723+
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
707724
echo
708725

709726
# :command.usage_examples
@@ -747,20 +764,20 @@ rush_list_usage() {
747764
# :command.usage_flags
748765
# :flag.usage
749766
echo " --simple, -s"
750-
printf " Show only package names.\n"
767+
printf " Show only package names\n"
751768
echo
752769

753770
# :flag.usage
754771
echo " --all, -a"
755-
printf " Show nested packages as well.\n"
772+
printf " Show nested packages as well\n"
756773
echo
757774

758775
# :command.usage_args
759776
printf "Arguments:\n"
760777

761778
# :argument.usage
762779
echo " REPO_OR_PACKAGE"
763-
printf " Repository name or package name.\n - Leave blank to show all packages in all repositories.\n - Provide a repository name to show only packages in this repository.\n - Provide a package name (may be in the form of 'repo:package') to\n show nested packages.\n"
780+
printf " Repository name or package name\n - Leave blank to show all packages in all repositories.\n - Provide a repository name to show only packages in this repository.\n - Provide a package name (may be in the form of 'repo:package') to\n show nested packages.\n"
764781
echo
765782

766783
# :command.usage_examples
@@ -809,7 +826,7 @@ rush_search_usage() {
809826

810827
# :argument.usage
811828
echo " TEXT"
812-
printf " Text to search for.\n"
829+
printf " Text to search for\n"
813830
echo
814831

815832
fi
@@ -849,12 +866,12 @@ rush_edit_usage() {
849866

850867
# :argument.usage
851868
echo " PACKAGE"
852-
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
869+
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
853870
echo
854871

855872
# :argument.usage
856873
echo " FILE"
857-
printf " File to edit.\n Default: main\n"
874+
printf " File to edit\n Default: main\n"
858875
echo
859876

860877
fi
@@ -891,12 +908,12 @@ rush_show_usage() {
891908

892909
# :argument.usage
893910
echo " PACKAGE"
894-
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
911+
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
895912
echo
896913

897914
# :argument.usage
898915
echo " FILE"
899-
printf " File to show (show all if not specified).\n"
916+
printf " File to show (show all if not specified)\n"
900917
echo
901918

902919
fi
@@ -1545,6 +1562,7 @@ rush_undo_command() {
15451562
# Collect variables
15461563
package=${args[package]}
15471564
repo="default"
1565+
export VERBOSE=${args['--verbose']}
15481566

15491567
if [[ $package =~ (.*):(.*) ]]; then
15501568
repo=${BASH_REMATCH[1]}
@@ -1593,6 +1611,8 @@ rush_snatch_command() {
15931611
repo_id=${args[github_user]}
15941612
package=${args[package]}
15951613
path="$HOME/rush-repos/snatched"
1614+
export FORCE=${args['--force']}
1615+
export VERBOSE=${args['--verbose']}
15961616

15971617
cleanup() {
15981618
rush remove snatched --purge
@@ -2577,6 +2597,13 @@ rush_undo_parse_requirements() {
25772597
while [[ $# -gt 0 ]]; do
25782598
key="$1"
25792599
case "$key" in
2600+
# :flag.case
2601+
--verbose | -v )
2602+
2603+
# :flag.case_no_arg
2604+
args[--verbose]=1
2605+
shift
2606+
;;
25802607

25812608
-?* )
25822609
printf "invalid option: %s\n" "$key" >&2
@@ -2601,7 +2628,7 @@ rush_undo_parse_requirements() {
26012628
done
26022629
# :command.required_args_filter
26032630
if [[ -z ${args[package]+x} ]]; then
2604-
printf "missing required argument: PACKAGE\nusage: rush undo PACKAGE\n" >&2
2631+
printf "missing required argument: PACKAGE\nusage: rush undo PACKAGE [OPTIONS]\n" >&2
26052632
exit 1
26062633
fi
26072634

@@ -2626,6 +2653,21 @@ rush_snatch_parse_requirements() {
26262653
while [[ $# -gt 0 ]]; do
26272654
key="$1"
26282655
case "$key" in
2656+
# :flag.case
2657+
--force | -f )
2658+
2659+
# :flag.case_no_arg
2660+
args[--force]=1
2661+
shift
2662+
;;
2663+
2664+
# :flag.case
2665+
--verbose | -v )
2666+
2667+
# :flag.case_no_arg
2668+
args[--verbose]=1
2669+
shift
2670+
;;
26292671

26302672
-?* )
26312673
printf "invalid option: %s\n" "$key" >&2
@@ -2654,11 +2696,11 @@ rush_snatch_parse_requirements() {
26542696
done
26552697
# :command.required_args_filter
26562698
if [[ -z ${args[github_user]+x} ]]; then
2657-
printf "missing required argument: GITHUB_USER\nusage: rush snatch GITHUB_USER PACKAGE\n" >&2
2699+
printf "missing required argument: GITHUB_USER\nusage: rush snatch GITHUB_USER PACKAGE [OPTIONS]\n" >&2
26582700
exit 1
26592701
fi
26602702
if [[ -z ${args[package]+x} ]]; then
2661-
printf "missing required argument: PACKAGE\nusage: rush snatch GITHUB_USER PACKAGE\n" >&2
2703+
printf "missing required argument: PACKAGE\nusage: rush snatch GITHUB_USER PACKAGE [OPTIONS]\n" >&2
26622704
exit 1
26632705
fi
26642706

sample-repo/download/undo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22
set -e
3-
rm $USER_CWD/.somefile
3+
rm -f $USER_CWD/.somefile
44
echo "Removed '.somefile' from the current directory"

0 commit comments

Comments
 (0)