Browse code

improve user experience and consistency

Nat! authored on 08-09-2016 11:18:44
Showing 5 changed files
... ...
@@ -1,11 +1,11 @@
1 1
 2.0
2 2
 ===
3 3
 
4
-## YOUR OLD STUFF MAY NOT RUN ANYMORE
4
+### YOUR OLD STUFF MAY NOT RUN ANYMORE
5 5
 
6 6
 Do a `mulle-bootstrap dist clean`.
7 7
 
8
-## YOUR OLD SETTINGS MAY NOT WORK ANYMORE!
8
+### YOUR OLD SETTINGS MAY NOT WORK ANYMORE!
9 9
 
10 10
 Move all repo specific setting directories from
11 11
 
... ...
@@ -15,6 +15,10 @@ to
15 15
 
16 16
 `.bootstrap/<reponame>`
17 17
 
18
+### YOUR OLD SCRIPTS MAY NOT WORK ANYMORE!
19
+
20
+* Fetch script names have changed. *-install.sh is now *-fetch.sh.
21
+
18 22
 
19 23
 ## Changes
20 24
 
... ...
@@ -41,7 +45,7 @@ inheritance scheme.
41 45
 * UNAME is now simplified and lowercased(!)
42 46
 * redid the settings merge and inheritance logic. It's now a bit more scrutable.
43 47
 * removed build_order from settings
44
-
48
+* script names have changed. For instance, post-install.sh is now post-fetch.sh.
45 49
 
46 50
 
47 51
 1.1
... ...
@@ -136,10 +136,10 @@ Root scripts must be aware, that they will be called for every repository.
136 136
 4. `.bootstrap/settings/bin`
137 137
 5. `.bootstrap/public_settings/bin` (Inheritable)
138 138
 
139
-`pre-install.sh`
140
-`post-install.sh`
141
-`pre-upgrade.sh`
142
-`post-upgrade.sh`
139
+`pre-fetch.sh`
140
+`post-fetch.sh`
141
+`pre-update.sh`
142
+`post-update.sh`
143 143
 `pre-tag.sh`
144 144
 `post-tag.sh`
145 145
 
... ...
@@ -333,10 +333,10 @@ bootstrap_main()
333 333
 
334 334
          if [ "${DONT_RECURSE}" = "" ]
335 335
          then
336
-            fetch_main install "$@"      || exit 1
337
-            refresh_main                 || exit 1
336
+            fetch_main "$@"     || exit 1
337
+            refresh_main                  || exit 1
338 338
         else
339
-            fetch_main install --non-recursive "$@" || exit 1
339
+            fetch_main --non-recursive "$@" || exit 1
340 340
             refresh_main nonrecursive    || exit 1
341 341
          fi
342 342
 
... ...
@@ -384,14 +384,14 @@ bootstrap_main()
384 384
       fetch)
385 385
          . mulle-bootstrap-fetch.sh
386 386
 
387
-         DONT_ASK_AFTER_WARNING=YES fetch_main install "$@" || exit 1
387
+         DONT_ASK_AFTER_WARNING=YES fetch_main "$@" || exit 1
388 388
          refresh_main || exit 1
389 389
       ;;
390 390
 
391 391
       update)
392 392
          . mulle-bootstrap-fetch.sh
393 393
 
394
-         fetch_main update "$@" || exit 1
394
+         update_main "$@" || exit 1
395 395
          refresh_main || exit 1
396 396
       ;;
397 397
 
... ...
@@ -42,17 +42,23 @@ fetch_usage()
42 42
 {
43 43
    cat <<EOF >&2
44 44
 usage:
45
-   mulle-bootstrap fetch [-f] <install|nonrecursive|update>
46
-   -f           :  override dirty harry check
47
-   -u           :  update also symlinked folders
48
-   install      :  clone or symlink non-exisiting repositories and other resources
49
-   nonrecursive :  like above, but ignore .bootstrap folders of repositories
50
-   update       :  execute `git pull` in fetched repositories
45
+   mulle-bootstrap ${COMMAND} [options] [repositories]
46
+
47
+   Options
48
+      -f    :  override dirty harry check
49
+      -u    :  try to update symlinked folders as well (not recommended)
50
+      -nr   :  ignore .bootstrap folders of fetched repositories
51
+
52
+   install  :  clone or symlink non-exisiting repositories and other resources
53
+   update   :  execute a "pull" in fetched repositories
51 54
 
52 55
    You can specify the names of the repositories to update.
53
-   Currently available names are:
54 56
 EOF
55
-   (cd "${CLONESFETCH_SUBDIR}" ; ls -1 ) 2> /dev/null
57
+   if [ -d "${CLONESFETCH_SUBDIR}" ]
58
+   then
59
+      echo "Currently available repositories are:"
60
+      (cd "${CLONESFETCH_SUBDIR}" ; ls -1 | sed 's/^/   /')
61
+   fi
56 62
    exit 1
57 63
 }
58 64
 
... ...
@@ -315,7 +321,7 @@ link_command()
315 321
       fail "${C_RESET}${C_BOLD}${dstdir}/${src}${C_ERROR} does not exist ($PWD)"
316 322
    fi
317 323
 
318
-   if [ "${COMMAND}" = "install" ]
324
+   if [ "${COMMAND}" = "fetch" ]
319 325
    then
320 326
       #
321 327
       # relative paths look nicer, but could fail in more complicated
... ...
@@ -668,7 +674,7 @@ checkout_repository()
668 674
          checkout "$@"
669 675
          flag=1
670 676
 
671
-         if [ "${COMMAND}" = "install" -a "${DONT_RECURSE}" = "" ]
677
+         if [ "${COMMAND}" = "fetch" -a "${DONT_RECURSE}" = "" ]
672 678
          then
673 679
             local old_bootstrap
674 680
 
... ...
@@ -1288,28 +1294,14 @@ update_embedded_repositories()
1288 1294
 }
1289 1295
 
1290 1296
 
1291
-fetch_main()
1297
+_common_main()
1292 1298
 {
1293
-   log_fluff "::: fetch begin :::"
1294
-
1295
-   COMMAND="${1:-install}"
1296
-   [ $# -ne 0 ] && shift
1297
-
1298
-   case "$COMMAND" in
1299
-      install|update)
1300
-         ;;
1301
-      *)
1302
-         log_error "unknown command \"$COMMAND\""
1303
-         fetch_usage
1304
-         ;;
1305
-   esac
1306
-
1307 1299
 
1308 1300
    while [ $# -ne 0 ]
1309 1301
    do
1310 1302
       case "$1" in
1311 1303
          -h|-help|--help)
1312
-            fetch_usage
1304
+            ${USAGE}
1313 1305
          ;;
1314 1306
 
1315 1307
          -nr|--no-recursion)
... ...
@@ -1324,13 +1316,13 @@ fetch_main()
1324 1316
             MULLE_BOOTSTRAP_UPDATE_SYMLINKS="YES"
1325 1317
          ;;
1326 1318
 
1327
-
1328 1319
          -*)
1329 1320
             log_error "unknown option $1"
1330
-            fetch_usage
1321
+            ${USAGE}
1322
+
1331 1323
          ;;
1332 1324
 
1333
-         ""|*)
1325
+         *)
1334 1326
             break
1335 1327
          ;;
1336 1328
       esac
... ...
@@ -1362,19 +1354,19 @@ fetch_main()
1362 1354
    #
1363 1355
    DO_CHECK_USR_LOCAL_INCLUDE="`read_config_setting "check_usr_local_include" "NO"`"
1364 1356
 
1365
-   if [ "${COMMAND}" = "install" ]
1357
+   if [ "${COMMAND}" = "fetch" ]
1366 1358
    then
1367 1359
       if [ $# -ne 0 ]
1368 1360
       then
1369 1361
          log_error  "Additional parameters not allowed for install"
1370
-         fetch_usage
1362
+         ${USAGE}
1371 1363
       fi
1372 1364
    fi
1373 1365
 
1374 1366
    #
1375 1367
    # Run prepare scripts if present
1376 1368
    #
1377
-   if [ "${COMMAND}" = "install" ]
1369
+   if [ "${COMMAND}" = "fetch" ]
1378 1370
    then
1379 1371
        install_brews
1380 1372
 #
... ...
@@ -1398,7 +1390,6 @@ fetch_main()
1398 1390
       else
1399 1391
          log_info "Nothing to update, fetch first"
1400 1392
 
1401
-         log_fluff "::: fetch end :::"
1402 1393
          return 0
1403 1394
       fi
1404 1395
    fi
... ...
@@ -1423,6 +1414,29 @@ fetch_main()
1423 1414
          append_dir_to_gitignore_if_needed "${CLONES_SUBDIR}"
1424 1415
       fi
1425 1416
    fi
1417
+}
1418
+
1419
+
1420
+update_main()
1421
+{
1422
+   log_fluff "::: update begin :::"
1423
+
1424
+   USAGE="fetch_usage"
1425
+   COMMAND="update"
1426
+   _common_main "$@"
1427
+
1428
+   log_fluff "::: update end :::"
1429
+}
1430
+
1431
+
1432
+
1433
+fetch_main()
1434
+{
1435
+   log_fluff "::: fetch begin :::"
1436
+
1437
+   USAGE="fetch_usage"
1438
+   COMMAND="fetch"
1439
+   _common_main "$@"
1426 1440
 
1427 1441
    log_fluff "::: fetch end :::"
1428 1442
 }
... ...
@@ -37,7 +37,7 @@ xcode_usage()
37 37
 {
38 38
    cat <<EOF >&2
39 39
 usage:
40
-   mulle-bootstrap xcode <add|remove> [xcodeproj]
40
+   mulle-bootstrap xcode [<add|remove> [xcodeproj]
41 41
 
42 42
    add      : add settings to Xcode project (default)
43 43
    remove   : remove settings from Xcode project
... ...
@@ -386,22 +386,45 @@ xcode_main()
386 386
       fail "for now xcode only works on OS X"
387 387
    fi
388 388
 
389
-   COMMAND="${1:-add}"
390
-   [ $# -eq 0 ] || shift
389
+   while [ $# -ne 0 ]
390
+   do
391
+      case "$1" in
392
+         -h|-help|--help)
393
+            xcode_usage
394
+         ;;
391 395
 
392
-   PROJECT="$1"
396
+         -*)
397
+            log_error "unknown option $1"
398
+            xcode_usage
399
+         ;;
400
+
401
+         *)
402
+            break
403
+         ;;
404
+      esac
405
+
406
+      shift
407
+   done
408
+
409
+
410
+   COMMAND="${1:-add}"
393 411
    [ $# -eq 0 ] || shift
394 412
 
395 413
    case "$COMMAND" in
396
-      add)
397
-      ;;
398
-      remove)
414
+      add|remove)
415
+         :
399 416
       ;;
417
+
400 418
       *)
401 419
          log_error "Unknown command \"${COMMAND}\""
402
-         xcode_usage 
420
+         xcode_usage
403 421
       ;;
404 422
    esac
405 423
 
424
+
425
+   PROJECT="$1"
426
+   [ $# -eq 0 ] || shift
427
+
428
+
406 429
    patch_xcode_project "$@"
407 430
 }