Debian Codegraph @

cli/src/commands/git/remote/mod.rs

raw
1 // Copyright 2020-2023 The Jujutsu Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 mod add;
16 mod list;
17 mod remove;
18 mod rename;
19 mod set_url;
20
21 use clap::Subcommand;
22
23 use self::add::GitRemoteAddArgs;
24 use self::add::cmd_git_remote_add;
25 use self::list::GitRemoteListArgs;
26 use self::list::cmd_git_remote_list;
27 use self::remove::GitRemoteRemoveArgs;
28 use self::remove::cmd_git_remote_remove;
29 use self::rename::GitRemoteRenameArgs;
30 use self::rename::cmd_git_remote_rename;
31 use self::set_url::GitRemoteSetUrlArgs;
32 use self::set_url::cmd_git_remote_set_url;
33 use crate::cli_util::CommandHelper;
34 use crate::command_error::CommandError;
35 use crate::ui::Ui;
36
37 /// Manage Git remotes
38 ///
39 /// The Git repo will be a bare git repo stored inside the `.jj/` directory.
40 #[derive(Subcommand, Clone, Debug)]
41 pub enum RemoteCommand {
42 Add(GitRemoteAddArgs),
43 List(GitRemoteListArgs),
44 Remove(GitRemoteRemoveArgs),
45 Rename(GitRemoteRenameArgs),
46 SetUrl(GitRemoteSetUrlArgs),
47 }
48
49 pub async fn cmd_git_remote(
50 ui: &mut Ui,
51 command: &CommandHelper,
52 subcommand: &RemoteCommand,
53 ) -> Result<(), CommandError> {
54 match subcommand {
55 RemoteCommand::Add(args) => cmd_git_remote_add(ui, command, args).await,
56 RemoteCommand::List(args) => cmd_git_remote_list(ui, command, args).await,
57 RemoteCommand::Remove(args) => cmd_git_remote_remove(ui, command, args).await,
58 RemoteCommand::Rename(args) => cmd_git_remote_rename(ui, command, args).await,
59 RemoteCommand::SetUrl(args) => cmd_git_remote_set_url(ui, command, args).await,
60 }
61 }