Skip to content

Commit 2b71045

Browse files
derrickstoleegitster
authored andcommitted
scalar: implement 'scalar list'
The produced list simply consists of those repositories registered under the multi-valued `scalar.repo` config setting in the user's Git config. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5f0842 commit 2b71045

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

contrib/scalar/scalar.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,16 @@ static int unregister_dir(void)
251251
return res;
252252
}
253253

254+
static int cmd_list(int argc, const char **argv)
255+
{
256+
if (argc != 1)
257+
die(_("`scalar list` does not take arguments"));
258+
259+
if (run_git("config", "--global", "--get-all", "scalar.repo", NULL) < 0)
260+
return -1;
261+
return 0;
262+
}
263+
254264
static int cmd_register(int argc, const char **argv)
255265
{
256266
struct option options[] = {
@@ -337,6 +347,7 @@ static struct {
337347
const char *name;
338348
int (*fn)(int, const char **);
339349
} builtins[] = {
350+
{ "list", cmd_list },
340351
{ "register", cmd_register },
341352
{ "unregister", cmd_unregister },
342353
{ NULL, NULL},

contrib/scalar/scalar.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ scalar - an opinionated repository management tool
88
SYNOPSIS
99
--------
1010
[verse]
11+
scalar list
1112
scalar register [<enlistment>]
1213
scalar unregister [<enlistment>]
1314

@@ -28,11 +29,19 @@ an existing Git worktree with Scalar whose name is not `src`, the enlistment
2829
will be identical to the worktree.
2930

3031
The `scalar` command implements various subcommands, and different options
31-
depending on the subcommand.
32+
depending on the subcommand. With the exception of `list`, all subcommands
33+
expect to be run in an enlistment.
3234

3335
COMMANDS
3436
--------
3537

38+
List
39+
~~~~
40+
41+
list::
42+
List enlistments that are currently registered by Scalar. This
43+
subcommand does not need to be run inside an enlistment.
44+
3645
Register
3746
~~~~~~~~
3847

0 commit comments

Comments
 (0)