| 1 |
// Copyright 2020 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 forget; |
| 17 |
mod list; |
| 18 |
mod rename; |
| 19 |
mod root; |
| 20 |
mod update_stale; |
| 21 |
|
| 22 |
use clap::Subcommand; |
| 23 |
use tracing::instrument; |
| 24 |
|
| 25 |
use self::add::WorkspaceAddArgs; |
| 26 |
use self::add::cmd_workspace_add; |
| 27 |
use self::forget::WorkspaceForgetArgs; |
| 28 |
use self::forget::cmd_workspace_forget; |
| 29 |
use self::list::WorkspaceListArgs; |
| 30 |
use self::list::cmd_workspace_list; |
| 31 |
use self::rename::WorkspaceRenameArgs; |
| 32 |
use self::rename::cmd_workspace_rename; |
| 33 |
use self::root::WorkspaceRootArgs; |
| 34 |
use self::root::cmd_workspace_root; |
| 35 |
use self::update_stale::WorkspaceUpdateStaleArgs; |
| 36 |
use self::update_stale::cmd_workspace_update_stale; |
| 37 |
use crate::cli_util::CommandHelper; |
| 38 |
use crate::command_error::CommandError; |
| 39 |
use crate::ui::Ui; |
| 40 |
|
| 41 |
/// Commands for working with workspaces |
| 42 |
/// |
| 43 |
/// Workspaces let you add additional working copies attached to the same repo. |
| 44 |
/// A common use case is so you can run a slow build or test in one workspace |
| 45 |
/// while you're continuing to write code in another workspace. |
| 46 |
/// |
| 47 |
/// Each workspace has its own working-copy commit. When you have more than one |
| 48 |
/// workspace attached to a repo, they are indicated by `<workspace name>@` in |
| 49 |
/// `jj log`. |
| 50 |
/// |
| 51 |
/// Each workspace also has own sparse patterns. |
| 52 |
#[derive(Subcommand, Clone, Debug)] |
| 53 |
pub(crate) enum WorkspaceCommand { |
| 54 |
Add(WorkspaceAddArgs), |
| 55 |
Forget(WorkspaceForgetArgs), |
| 56 |
List(WorkspaceListArgs), |
| 57 |
Rename(WorkspaceRenameArgs), |
| 58 |
Root(WorkspaceRootArgs), |
| 59 |
UpdateStale(WorkspaceUpdateStaleArgs), |
| 60 |
} |
| 61 |
|
| 62 |
#[instrument(skip_all)] |
| 63 |
pub(crate) async fn cmd_workspace( |
| 64 |
ui: &mut Ui, |
| 65 |
command: &CommandHelper, |
| 66 |
subcommand: &WorkspaceCommand, |
| 67 |
) -> Result<(), CommandError> { |
| 68 |
match subcommand { |
| 69 |
WorkspaceCommand::Add(args) => cmd_workspace_add(ui, command, args).await, |
| 70 |
WorkspaceCommand::Forget(args) => cmd_workspace_forget(ui, command, args).await, |
| 71 |
WorkspaceCommand::List(args) => cmd_workspace_list(ui, command, args).await, |
| 72 |
WorkspaceCommand::Rename(args) => cmd_workspace_rename(ui, command, args).await, |
| 73 |
WorkspaceCommand::Root(args) => cmd_workspace_root(ui, command, args).await, |
| 74 |
WorkspaceCommand::UpdateStale(args) => cmd_workspace_update_stale(ui, command, args).await, |
| 75 |
} |
| 76 |
} |