use crate::palette::command::{CommandCategory, CommandDef, CommandId};
use crate::app::Action;
pub fn remote_commands() -> Vec<CommandDef> {
vec![
CommandDef {
id: CommandId::Push,
name: "Push",
key: "P",
category: CommandCategory::Remote,
description: "Push current branch to remote",
action_factory: |_| Some(Action::Push),
is_enabled: |_| true,
keywords: &["push", "upload", "remote"],
},
CommandDef {
id: CommandId::ForcePush,
name: "Force push (--force-with-lease)",
key: "fP",
category: CommandCategory::Remote,
description: "Force push with --force-with-lease (safer than --force)",
action_factory: |_| Some(Action::ForcePushAfterAmend),
is_enabled: |_| true,
keywords: &["force", "push", "lease", "amend"],
},
CommandDef {
id: CommandId::Pull,
name: "Pull (ff-only)",
key: "pl",
category: CommandCategory::Remote,
description: "Pull with fast-forward only",
action_factory: |_| Some(Action::Pull),
is_enabled: |_| true,
keywords: &["pull", "fetch", "update"],
},
CommandDef {
id: CommandId::PullRebase,
name: "Pull --rebase",
key: "pr",
category: CommandCategory::Remote,
description: "Pull with rebase",
action_factory: |_| Some(Action::PullRebase),
is_enabled: |_| true,
keywords: &["pull", "rebase", "update"],
},
CommandDef {
id: CommandId::PullMerge,
name: "Pull (merge)",
key: "pm",
category: CommandCategory::Remote,
description: "Pull with merge (regular pull)",
action_factory: |_| Some(Action::PullMerge),
is_enabled: |_| true,
keywords: &["pull", "merge", "update"],
},
CommandDef {
id: CommandId::FetchAllPrune,
name: "Fetch all --prune",
key: "fa",
category: CommandCategory::Remote,
description: "Fetch all remotes and prune deleted branches",
action_factory: |_| Some(Action::FetchAllPrune),
is_enabled: |_| true,
keywords: &["fetch", "all", "prune", "remote"],
},
CommandDef {
id: CommandId::RemotePrune,
name: "Remote prune (confirm)",
key: "rp",
category: CommandCategory::Remote,
description: "Prune remote branches (with confirmation)",
action_factory: |state| {
if !state.remotes.is_empty() {
Some(Action::RequestRemotePrune(state.remotes[0].name.clone()))
} else {
None
}
},
is_enabled: |state| !state.remotes.is_empty(),
keywords: &["remote", "prune", "cleanup"],
},
CommandDef {
id: CommandId::ShowRemoteUrl,
name: "Show remote URL",
key: "ru",
category: CommandCategory::Remote,
description: "Show remote URL",
action_factory: |state| {
if !state.remotes.is_empty() {
Some(Action::ShowRemoteUrl(state.remotes[0].name.clone()))
} else {
None
}
},
is_enabled: |state| !state.remotes.is_empty(),
keywords: &["remote", "url", "show"],
},
CommandDef {
id: CommandId::SetRemoteSsh,
name: "Set remote to SSH",
key: "rs",
category: CommandCategory::Remote,
description: "Set remote URL to SSH format",
action_factory: |state| {
if !state.remotes.is_empty() {
Some(Action::SetRemoteSsh(state.remotes[0].name.clone()))
} else {
None
}
},
is_enabled: |state| !state.remotes.is_empty(),
keywords: &["remote", "ssh", "set"],
},
]
}