Skip to content

repo_on_fire.cli

Definition of the command line interface of the application.

This module defines the available command line interface of the app. Most of the concrete commands are simple wrappers around the native repo commands. However, repo-on-fire also has some own ones. Additionally, the tool decorates some of repo's built in commands, adding some functionality on top.

abandon(args)

Permanently abandon a development branch.

Source code in repo_on_fire/cli.py
31
32
33
34
35
36
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def abandon(args: List[str]):
    """Permanently abandon a development branch."""
    app = Application()
    app.run_native_repo_command("abandon", args)

branch(args)

View current topic branches.

Source code in repo_on_fire/cli.py
39
40
41
42
43
44
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def branch(args: List[str]):
    """View current topic branches."""
    app = Application()
    app.run_native_repo_command("branch", args)

branches(args)

View current topic branches.

Source code in repo_on_fire/cli.py
47
48
49
50
51
52
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def branches(args: List[str]):
    """View current topic branches."""
    app = Application()
    app.run_native_repo_command("branches", args)

checkout(args)

Checkout a branch for development.

Source code in repo_on_fire/cli.py
55
56
57
58
59
60
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def checkout(args: List[str]):
    """Checkout a branch for development."""
    app = Application()
    app.run_native_repo_command("checkout", args)

cherry_pick(args)

Cherry-pick a change..

Source code in repo_on_fire/cli.py
63
64
65
66
67
68
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def cherry_pick(args: List[str]):
    """Cherry-pick a change.."""
    app = Application()
    app.run_native_repo_command("cherry-pick", args)

cli()

This tool is a wrapper around the repo command line tool.

It allows calling any repo command as usual. On top, some repo-on-fire specific commands are added on top.

Source code in repo_on_fire/cli.py
17
18
19
20
21
22
23
@click.group("Repo on Fire Commands")
def cli():
    """This tool is a wrapper around the repo command line tool.

    It allows calling any repo command as usual. On top, some repo-on-fire
    specific commands are added on top.
    """

config()

Configuration of the tool.

Source code in repo_on_fire/cli.py
346
347
348
@cli.group()
def config():
    """Configuration of the tool."""

config_list(json)

Print the current configuration.

Source code in repo_on_fire/cli.py
358
359
360
361
362
@config.command(name="list")
@click.option("--json", is_flag=True, help="Print as JSON.")
def config_list(json: bool):
    """Print the current configuration."""
    Application().list_config(print_as_json=json)

config_path(json)

Print the path to the user configuration file.

Source code in repo_on_fire/cli.py
351
352
353
354
355
@config.command(name="path")
@click.option("--json", is_flag=True, help="Print as JSON.")
def config_path(json: bool):
    """Print the path to the user configuration file."""
    Application().show_config_file_path(print_as_json=json)

diff(args)

Show changes between commit and working tree.

Source code in repo_on_fire/cli.py
71
72
73
74
75
76
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def diff(args: List[str]):
    """Show changes between commit and working tree."""
    app = Application()
    app.run_native_repo_command("diff", args)

diffmanifests(args)

Manifest diff utility.

Source code in repo_on_fire/cli.py
79
80
81
82
83
84
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def diffmanifests(args: List[str]):
    """Manifest diff utility."""
    app = Application()
    app.run_native_repo_command("diffmanifests", args)

download(args)

Download and checkout a change.

Source code in repo_on_fire/cli.py
87
88
89
90
91
92
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def download(args: List[str]):
    """Download and checkout a change."""
    app = Application()
    app.run_native_repo_command("download", args)

forall(args)

Run a shell command in each project.

Source code in repo_on_fire/cli.py
 95
 96
 97
 98
 99
100
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def forall(args: List[str]):
    """Run a shell command in each project."""
    app = Application()
    app.run_native_repo_command("forall", args)

grep(args)

Print lines matching a pattern.

Source code in repo_on_fire/cli.py
103
104
105
106
107
108
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def grep(args: List[str]):
    """Print lines matching a pattern."""
    app = Application()
    app.run_native_repo_command("grep", args)

help(args)

Display detailed help on a command.

Source code in repo_on_fire/cli.py
111
112
113
114
115
116
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def help(args: List[str]):
    """Display detailed help on a command."""
    app = Application()
    app.run_native_repo_command("help", args)

info(args)

Get info on the manifest branch, current branch or unmerged branches.

Source code in repo_on_fire/cli.py
119
120
121
122
123
124
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def info(args: List[str]):
    """Get info on the manifest branch, current branch or unmerged branches."""
    app = Application()
    app.run_native_repo_command("info", args)

init(args)

Stage file(s) for commit.

Source code in repo_on_fire/cli.py
127
128
129
130
131
132
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def init(args: List[str]):
    """Stage file(s) for commit."""
    app = Application()
    app.run_native_repo_command("init", args)

list(args)

List projects and their associated directories.

Source code in repo_on_fire/cli.py
135
136
137
138
139
140
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def list(args: List[str]):
    """List projects and their associated directories."""
    app = Application()
    app.run_native_repo_command("list", args)

manifest(args)

Manifest inspection utility.

Source code in repo_on_fire/cli.py
143
144
145
146
147
148
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def manifest(args: List[str]):
    """Manifest inspection utility."""
    app = Application()
    app.run_native_repo_command("manifest", args)

overview(args)

Display overview of unmerged project branches.

Source code in repo_on_fire/cli.py
151
152
153
154
155
156
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def overview(args: List[str]):
    """Display overview of unmerged project branches."""
    app = Application()
    app.run_native_repo_command("overview", args)

prune(args)

Prune (delete) already merged topics.

Source code in repo_on_fire/cli.py
159
160
161
162
163
164
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def prune(args: List[str]):
    """Prune (delete) already merged topics."""
    app = Application()
    app.run_native_repo_command("prune", args)

rebase(args)

Rebase local branches on upstream branch.

Source code in repo_on_fire/cli.py
167
168
169
170
171
172
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def rebase(args: List[str]):
    """Rebase local branches on upstream branch."""
    app = Application()
    app.run_native_repo_command("rebase", args)

selfupdate(args)

Update repo to the latest version.

Source code in repo_on_fire/cli.py
175
176
177
178
179
180
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def selfupdate(args: List[str]):
    """Update repo to the latest version."""
    app = Application()
    app.run_native_repo_command("selfupdate", args)

smartsync(args)

Update working tree to the latest known good revision.

Source code in repo_on_fire/cli.py
183
184
185
186
187
188
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def smartsync(args: List[str]):
    """Update working tree to the latest known good revision."""
    app = Application()
    app.run_native_repo_command("smartsync", args)

stage(args)

Stage file(s) for commit.

Source code in repo_on_fire/cli.py
191
192
193
194
195
196
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def stage(args: List[str]):
    """Stage file(s) for commit."""
    app = Application()
    app.run_native_repo_command("stage", args)

start(args)

Start a new branch for development.

Source code in repo_on_fire/cli.py
199
200
201
202
203
204
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def start(args: List[str]):
    """Start a new branch for development."""
    app = Application()
    app.run_native_repo_command("start", args)

status(args)

Show the working tree status.

Source code in repo_on_fire/cli.py
207
208
209
210
211
212
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def status(args: List[str]):
    """Show the working tree status."""
    app = Application()
    app.run_native_repo_command("status", args)

sync(args)

Update working tree to the latest revision.

Source code in repo_on_fire/cli.py
215
216
217
218
219
220
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def sync(args: List[str]):
    """Update working tree to the latest revision."""
    app = Application()
    app.run_native_repo_command("sync", args)

unknown(args)

Catch all other repo commands and forward them to the default command.

Source code in repo_on_fire/cli.py
244
245
246
247
248
249
250
251
252
253
254
255
@cli.command(
    context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
    add_help_option=False,
)
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def unknown(args):
    """Catch all other repo commands and forward them to the default command."""
    app = Application()
    if len(args) > 0:
        app.run_native_repo_command(args[0], args[1:])
    else:
        app.run_repo(args)

upload(args)

Upload changes for code review.

Source code in repo_on_fire/cli.py
223
224
225
226
227
228
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def upload(args: List[str]):
    """Upload changes for code review."""
    app = Application()
    app.run_native_repo_command("upload", args)

version(args)

Display the version of repo.

Source code in repo_on_fire/cli.py
231
232
233
234
235
236
@cli.command(add_help_option=False, context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def version(args: List[str]):
    """Display the version of repo."""
    app = Application()
    app.run_native_repo_command("version", args)

workspace()

Workspace manipulation commands.

Source code in repo_on_fire/cli.py
315
316
317
@cli.group()
def workspace():
    """Workspace manipulation commands."""

workspace_snapshot(output)

Create a frozen workspace snapshot manifest.

Source code in repo_on_fire/cli.py
336
337
338
339
340
341
342
343
@workspace.command(name="snapshot")
@click.option("-o", "--output", type=click.Path(path_type=Path), help="Write manifest to file.")
def workspace_snapshot(output: Optional[Path]):
    """Create a frozen workspace snapshot manifest."""
    app = Application()
    manifest = app.workspace.snapshot(output=output)
    if output is None:
        click.echo(manifest, nl=False)

workspace_switch(branch)

Switch the workspace to a different branch.

This will first run a sync on the workspace, detaching any potentially checked out branches. Afterwards, an attempt is made to check out the given branch in all repositories in the workspace.

If the branch can be checked out in at least one repository, the call succeeds, otherwise, the command exits with an error.

Source code in repo_on_fire/cli.py
320
321
322
323
324
325
326
327
328
329
330
331
332
333
@workspace.command(name="switch")
@click.argument("branch", type=str)
def workspace_switch(branch: str):
    """Switch the workspace to a different branch.

    This will first run a sync on the workspace, detaching any potentially
    checked out branches. Afterwards, an attempt is made to check out the
    given branch in all repositories in the workspace.

    If the branch can be checked out in at least one repository, the call
    succeeds, otherwise, the command exits with an error.
    """
    app = Application()
    app.workspace.switch(branch)