mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-28 07:20:11 +00:00
commands: move version code to version.rs
This commit is contained in:
parent
04eddc666c
commit
9e462509f8
2 changed files with 37 additions and 16 deletions
|
@ -52,6 +52,7 @@ mod status;
|
|||
mod unsquash;
|
||||
mod untrack;
|
||||
mod util;
|
||||
mod version;
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::io::Write;
|
||||
|
@ -145,15 +146,11 @@ enum Commands {
|
|||
Undo(operation::OperationUndoArgs),
|
||||
Unsquash(unsquash::UnsquashArgs),
|
||||
Untrack(untrack::UntrackArgs),
|
||||
Version(VersionArgs),
|
||||
Version(version::VersionArgs),
|
||||
#[command(subcommand)]
|
||||
Workspace(WorkspaceCommands),
|
||||
}
|
||||
|
||||
/// Display version information
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct VersionArgs {}
|
||||
|
||||
/// Commands for working with workspaces
|
||||
///
|
||||
/// Workspaces let you add additional working copies attached to the same repo.
|
||||
|
@ -215,16 +212,6 @@ struct WorkspaceRootArgs {}
|
|||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct WorkspaceUpdateStaleArgs {}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn cmd_version(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
_args: &VersionArgs,
|
||||
) -> Result<(), CommandError> {
|
||||
write!(ui.stdout(), "{}", command.app().render_version())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn show_predecessor_patch(
|
||||
ui: &Ui,
|
||||
formatter: &mut dyn Formatter,
|
||||
|
@ -629,7 +616,7 @@ pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), Co
|
|||
let derived_subcommands: Commands =
|
||||
Commands::from_arg_matches(command_helper.matches()).unwrap();
|
||||
match &derived_subcommands {
|
||||
Commands::Version(sub_args) => cmd_version(ui, command_helper, sub_args),
|
||||
Commands::Version(sub_args) => version::cmd_version(ui, command_helper, sub_args),
|
||||
Commands::Init(sub_args) => init::cmd_init(ui, command_helper, sub_args),
|
||||
Commands::Config(sub_args) => config::cmd_config(ui, command_helper, sub_args),
|
||||
Commands::Checkout(sub_args) => checkout::cmd_checkout(ui, command_helper, sub_args),
|
||||
|
|
34
cli/src/commands/version.rs
Normal file
34
cli/src/commands/version.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2020 The Jujutsu Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::cli_util::{CommandError, CommandHelper};
|
||||
use crate::ui::Ui;
|
||||
|
||||
/// Display version information
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
pub(crate) struct VersionArgs {}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
pub(crate) fn cmd_version(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
_args: &VersionArgs,
|
||||
) -> Result<(), CommandError> {
|
||||
write!(ui.stdout(), "{}", command.app().render_version())?;
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in a new issue