pub struct CommandHelper { /* private fields */ }
Implementations§
Source§impl CommandHelper
impl CommandHelper
pub fn app(&self) -> &Command
Sourcepub fn cwd(&self) -> &Path
pub fn cwd(&self) -> &Path
Canonical form of the current working directory path.
A loaded Workspace::workspace_root()
also returns a canonical path, so
relative paths can be easily computed from these paths.
pub fn string_args(&self) -> &Vec<String>
pub fn matches(&self) -> &ArgMatches
pub fn global_args(&self) -> &GlobalArgs
pub fn config_env(&self) -> &ConfigEnv
Sourcepub fn raw_config(&self) -> &RawConfig
pub fn raw_config(&self) -> &RawConfig
Unprocessed (or unresolved) configuration data.
Use this only if the unmodified config data is needed. For example, jj config set
should use this to write updated data back to file.
Sourcepub fn settings(&self) -> &UserSettings
pub fn settings(&self) -> &UserSettings
Settings for the current command and workspace.
This may be different from the settings for new workspace created by
e.g. jj git init
. There may be conditional variables and repo config
.jj/repo/config.toml
loaded for the cwd workspace.
Sourcepub fn settings_for_new_workspace(
&self,
workspace_root: &Path,
) -> Result<UserSettings, CommandError>
pub fn settings_for_new_workspace( &self, workspace_root: &Path, ) -> Result<UserSettings, CommandError>
Resolves configuration for new workspace located at the specified path.
Sourcepub fn text_editor(&self) -> Result<TextEditor, ConfigGetError>
pub fn text_editor(&self) -> Result<TextEditor, ConfigGetError>
Loads text editor from the settings.
pub fn revset_extensions(&self) -> &Arc<RevsetExtensions>
Sourcepub fn parse_template<'a, C, L>(
&self,
ui: &Ui,
language: &L,
template_text: &str,
) -> Result<TemplateRenderer<'a, C>, CommandError>
pub fn parse_template<'a, C, L>( &self, ui: &Ui, language: &L, template_text: &str, ) -> Result<TemplateRenderer<'a, C>, CommandError>
Parses template of the given language into evaluation tree.
This function also loads template aliases from the settings. Use
WorkspaceCommandHelper::parse_template()
if you’ve already
instantiated the workspace helper.
pub fn workspace_loader(&self) -> Result<&dyn WorkspaceLoader, CommandError>
Sourcepub fn workspace_helper(
&self,
ui: &Ui,
) -> Result<WorkspaceCommandHelper, CommandError>
pub fn workspace_helper( &self, ui: &Ui, ) -> Result<WorkspaceCommandHelper, CommandError>
Loads workspace and repo, then snapshots the working copy if allowed.
Sourcepub fn workspace_helper_with_stats(
&self,
ui: &Ui,
) -> Result<(WorkspaceCommandHelper, SnapshotStats), CommandError>
pub fn workspace_helper_with_stats( &self, ui: &Ui, ) -> Result<(WorkspaceCommandHelper, SnapshotStats), CommandError>
Loads workspace and repo, then snapshots the working copy if allowed and returns the SnapshotStats.
Note that unless you have a good reason not to do so, you should always
call print_snapshot_stats
with the SnapshotStats
returned by
this function to present possible untracked files to the user.
Sourcepub fn workspace_helper_no_snapshot(
&self,
ui: &Ui,
) -> Result<WorkspaceCommandHelper, CommandError>
pub fn workspace_helper_no_snapshot( &self, ui: &Ui, ) -> Result<WorkspaceCommandHelper, CommandError>
Loads workspace and repo, but never snapshots the working copy. Most
commands should use workspace_helper()
instead.
pub fn get_working_copy_factory( &self, ) -> Result<&dyn WorkingCopyFactory, CommandError>
Sourcepub fn load_workspace(&self) -> Result<Workspace, CommandError>
pub fn load_workspace(&self) -> Result<Workspace, CommandError>
Loads workspace for the current command.
Sourcepub fn load_workspace_at(
&self,
workspace_root: &Path,
settings: &UserSettings,
) -> Result<Workspace, CommandError>
pub fn load_workspace_at( &self, workspace_root: &Path, settings: &UserSettings, ) -> Result<Workspace, CommandError>
Loads workspace located at the specified path.
Sourcepub fn recover_stale_working_copy(
&self,
ui: &Ui,
) -> Result<(WorkspaceCommandHelper, SnapshotStats), CommandError>
pub fn recover_stale_working_copy( &self, ui: &Ui, ) -> Result<(WorkspaceCommandHelper, SnapshotStats), CommandError>
Note that unless you have a good reason not to do so, you should always
call print_snapshot_stats
with the SnapshotStats
returned by
this function to present possible untracked files to the user.
Sourcepub fn workspace_environment(
&self,
ui: &Ui,
workspace: &Workspace,
) -> Result<WorkspaceCommandEnvironment, CommandError>
pub fn workspace_environment( &self, ui: &Ui, workspace: &Workspace, ) -> Result<WorkspaceCommandEnvironment, CommandError>
Loads command environment for the given workspace
.
Sourcepub fn is_working_copy_writable(&self) -> bool
pub fn is_working_copy_writable(&self) -> bool
Returns true if the working copy to be loaded is writable, and therefore should usually be snapshotted.
Sourcepub fn is_at_head_operation(&self) -> bool
pub fn is_at_head_operation(&self) -> bool
Returns true if the current operation is considered to be the head.
Sourcepub fn resolve_operation(
&self,
ui: &Ui,
repo_loader: &RepoLoader,
) -> Result<Operation, CommandError>
pub fn resolve_operation( &self, ui: &Ui, repo_loader: &RepoLoader, ) -> Result<Operation, CommandError>
Resolves the current operation from the command-line argument.
If no --at-operation
is specified, the head operations will be
loaded. If there are multiple heads, they’ll be merged.
Sourcepub fn for_workable_repo(
&self,
ui: &Ui,
workspace: Workspace,
repo: Arc<ReadonlyRepo>,
) -> Result<WorkspaceCommandHelper, CommandError>
pub fn for_workable_repo( &self, ui: &Ui, workspace: Workspace, repo: Arc<ReadonlyRepo>, ) -> Result<WorkspaceCommandHelper, CommandError>
Creates helper for the repo whose view is supposed to be in sync with
the working copy. If --ignore-working-copy
is not specified, the
returned helper will attempt to update the working copy.
Trait Implementations§
Source§impl Clone for CommandHelper
impl Clone for CommandHelper
Source§fn clone(&self) -> CommandHelper
fn clone(&self) -> CommandHelper
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for CommandHelper
impl !RefUnwindSafe for CommandHelper
impl !Send for CommandHelper
impl !Sync for CommandHelper
impl Unpin for CommandHelper
impl !UnwindSafe for CommandHelper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more