Commit 0d330a5
maintenance: add parse-options boilerplate for subcommands
Several of the git-maintenance subcommands don't take any options, so
they don't bother looking at argv at all. This means they'll silently
accept garbage, like:
$ git maintenance register --foo
[no output]
$ git maintenance stop bar
[no output]
Let's give them the basic boilerplate to detect and handle these cases:
$ git maintenance register --foo
error: unknown option `foo'
usage: git maintenance register
$ git maintenance stop bar
usage: git maintenance stop
We could reduce the number of lines of code here a bit with a shared
helper function. But it's worth building out the boilerplate, as it may
serve as the base for adding options later.
Note one complication: maintenance_start() calls directly into
maintenance_register(), so it now needs to pass a plausible argv (we
don't care, but parse_options() is expecting there to at least be an
argv[0] program name). This is an extra line of code, but it eliminates
the need for an explanatory comment.
Signed-off-by: Jeff King <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent ecd2d3e commit 0d330a5
1 file changed
+42
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1465 | 1465 | | |
1466 | 1466 | | |
1467 | 1467 | | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
1468 | 1473 | | |
1469 | 1474 | | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
1470 | 1478 | | |
1471 | 1479 | | |
1472 | 1480 | | |
1473 | 1481 | | |
1474 | 1482 | | |
1475 | 1483 | | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
1476 | 1490 | | |
1477 | 1491 | | |
1478 | 1492 | | |
| |||
1509 | 1523 | | |
1510 | 1524 | | |
1511 | 1525 | | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
1512 | 1531 | | |
1513 | 1532 | | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
1514 | 1536 | | |
1515 | 1537 | | |
1516 | 1538 | | |
1517 | 1539 | | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
1518 | 1546 | | |
1519 | 1547 | | |
1520 | 1548 | | |
| |||
2496 | 2524 | | |
2497 | 2525 | | |
2498 | 2526 | | |
| 2527 | + | |
2499 | 2528 | | |
2500 | 2529 | | |
2501 | 2530 | | |
| |||
2505 | 2534 | | |
2506 | 2535 | | |
2507 | 2536 | | |
2508 | | - | |
| 2537 | + | |
2509 | 2538 | | |
2510 | 2539 | | |
2511 | 2540 | | |
2512 | 2541 | | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
2513 | 2547 | | |
2514 | 2548 | | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
2515 | 2556 | | |
2516 | 2557 | | |
2517 | 2558 | | |
| |||
0 commit comments