|
| 1 | +import { Commands } from '../constants.commands'; |
| 2 | +import type { Container } from '../container'; |
| 3 | +import { command } from '../system/vscode/command'; |
| 4 | +import type { CommandContext } from './base'; |
| 5 | +import type { BranchGitCommandArgs } from './git/branch'; |
| 6 | +import type { CherryPickGitCommandArgs } from './git/cherry-pick'; |
| 7 | +import type { CoAuthorsGitCommandArgs } from './git/coauthors'; |
| 8 | +import type { FetchGitCommandArgs } from './git/fetch'; |
| 9 | +import type { LogGitCommandArgs } from './git/log'; |
| 10 | +import type { MergeGitCommandArgs } from './git/merge'; |
| 11 | +import type { PullGitCommandArgs } from './git/pull'; |
| 12 | +import type { PushGitCommandArgs } from './git/push'; |
| 13 | +import type { RebaseGitCommandArgs } from './git/rebase'; |
| 14 | +import type { RemoteGitCommandArgs } from './git/remote'; |
| 15 | +import type { ResetGitCommandArgs } from './git/reset'; |
| 16 | +import type { RevertGitCommandArgs } from './git/revert'; |
| 17 | +import type { SearchGitCommandArgs } from './git/search'; |
| 18 | +import type { ShowGitCommandArgs } from './git/show'; |
| 19 | +import type { StashGitCommandArgs } from './git/stash'; |
| 20 | +import type { StatusGitCommandArgs } from './git/status'; |
| 21 | +import type { SwitchGitCommandArgs } from './git/switch'; |
| 22 | +import type { TagGitCommandArgs } from './git/tag'; |
| 23 | +import type { WorktreeGitCommandArgs } from './git/worktree'; |
| 24 | +import type { QuickWizardCommandArgsWithCompletion } from './quickWizard.base'; |
| 25 | +import { QuickWizardCommandBase } from './quickWizard.base'; |
| 26 | + |
| 27 | +export type GitWizardCommandArgs = |
| 28 | + | BranchGitCommandArgs |
| 29 | + | CherryPickGitCommandArgs |
| 30 | + | CoAuthorsGitCommandArgs |
| 31 | + | FetchGitCommandArgs |
| 32 | + | LogGitCommandArgs |
| 33 | + | MergeGitCommandArgs |
| 34 | + | PullGitCommandArgs |
| 35 | + | PushGitCommandArgs |
| 36 | + | RebaseGitCommandArgs |
| 37 | + | RemoteGitCommandArgs |
| 38 | + | ResetGitCommandArgs |
| 39 | + | RevertGitCommandArgs |
| 40 | + | SearchGitCommandArgs |
| 41 | + | ShowGitCommandArgs |
| 42 | + | StashGitCommandArgs |
| 43 | + | StatusGitCommandArgs |
| 44 | + | SwitchGitCommandArgs |
| 45 | + | TagGitCommandArgs |
| 46 | + | WorktreeGitCommandArgs; |
| 47 | + |
| 48 | +@command() |
| 49 | +export class GitWizardCommand extends QuickWizardCommandBase { |
| 50 | + constructor(container: Container) { |
| 51 | + super(container, [ |
| 52 | + Commands.GitCommands, |
| 53 | + Commands.GitCommandsBranch, |
| 54 | + Commands.GitCommandsBranchCreate, |
| 55 | + Commands.GitCommandsBranchDelete, |
| 56 | + Commands.GitCommandsBranchPrune, |
| 57 | + Commands.GitCommandsBranchRename, |
| 58 | + Commands.GitCommandsCheckout, |
| 59 | + Commands.GitCommandsCherryPick, |
| 60 | + Commands.GitCommandsHistory, |
| 61 | + Commands.GitCommandsMerge, |
| 62 | + Commands.GitCommandsRebase, |
| 63 | + Commands.GitCommandsRemote, |
| 64 | + Commands.GitCommandsRemoteAdd, |
| 65 | + Commands.GitCommandsRemotePrune, |
| 66 | + Commands.GitCommandsRemoteRemove, |
| 67 | + Commands.GitCommandsReset, |
| 68 | + Commands.GitCommandsRevert, |
| 69 | + Commands.GitCommandsShow, |
| 70 | + Commands.GitCommandsStash, |
| 71 | + Commands.GitCommandsStashDrop, |
| 72 | + Commands.GitCommandsStashList, |
| 73 | + Commands.GitCommandsStashPop, |
| 74 | + Commands.GitCommandsStashPush, |
| 75 | + Commands.GitCommandsStashRename, |
| 76 | + Commands.GitCommandsStatus, |
| 77 | + Commands.GitCommandsSwitch, |
| 78 | + Commands.GitCommandsTag, |
| 79 | + Commands.GitCommandsTagCreate, |
| 80 | + Commands.GitCommandsTagDelete, |
| 81 | + Commands.GitCommandsWorktree, |
| 82 | + Commands.GitCommandsWorktreeCreate, |
| 83 | + Commands.GitCommandsWorktreeDelete, |
| 84 | + Commands.GitCommandsWorktreeOpen, |
| 85 | + |
| 86 | + Commands.CopyWorkingChangesToWorktree, |
| 87 | + ]); |
| 88 | + } |
| 89 | + |
| 90 | + protected override preExecute( |
| 91 | + context: CommandContext, |
| 92 | + args?: QuickWizardCommandArgsWithCompletion<GitWizardCommandArgs>, |
| 93 | + ) { |
| 94 | + switch (context.command) { |
| 95 | + case Commands.GitCommandsBranch: |
| 96 | + return this.execute({ command: 'branch' }); |
| 97 | + case Commands.GitCommandsBranchCreate: |
| 98 | + return this.execute({ command: 'branch', state: { subcommand: 'create' } }); |
| 99 | + case Commands.GitCommandsBranchDelete: |
| 100 | + return this.execute({ command: 'branch', state: { subcommand: 'delete' } }); |
| 101 | + case Commands.GitCommandsBranchPrune: |
| 102 | + return this.execute({ command: 'branch', state: { subcommand: 'prune' } }); |
| 103 | + case Commands.GitCommandsBranchRename: |
| 104 | + return this.execute({ command: 'branch', state: { subcommand: 'rename' } }); |
| 105 | + case Commands.GitCommandsCherryPick: |
| 106 | + return this.execute({ command: 'cherry-pick' }); |
| 107 | + case Commands.GitCommandsHistory: |
| 108 | + return this.execute({ command: 'log' }); |
| 109 | + case Commands.GitCommandsMerge: |
| 110 | + return this.execute({ command: 'merge' }); |
| 111 | + case Commands.GitCommandsRebase: |
| 112 | + return this.execute({ command: 'rebase' }); |
| 113 | + case Commands.GitCommandsRemote: |
| 114 | + return this.execute({ command: 'remote' }); |
| 115 | + case Commands.GitCommandsRemoteAdd: |
| 116 | + return this.execute({ command: 'remote', state: { subcommand: 'add' } }); |
| 117 | + case Commands.GitCommandsRemotePrune: |
| 118 | + return this.execute({ command: 'remote', state: { subcommand: 'prune' } }); |
| 119 | + case Commands.GitCommandsRemoteRemove: |
| 120 | + return this.execute({ command: 'remote', state: { subcommand: 'remove' } }); |
| 121 | + case Commands.GitCommandsReset: |
| 122 | + return this.execute({ command: 'reset' }); |
| 123 | + case Commands.GitCommandsRevert: |
| 124 | + return this.execute({ command: 'revert' }); |
| 125 | + case Commands.GitCommandsShow: |
| 126 | + return this.execute({ command: 'show' }); |
| 127 | + case Commands.GitCommandsStash: |
| 128 | + return this.execute({ command: 'stash' }); |
| 129 | + case Commands.GitCommandsStashDrop: |
| 130 | + return this.execute({ command: 'stash', state: { subcommand: 'drop' } }); |
| 131 | + case Commands.GitCommandsStashList: |
| 132 | + return this.execute({ command: 'stash', state: { subcommand: 'list' } }); |
| 133 | + case Commands.GitCommandsStashPop: |
| 134 | + return this.execute({ command: 'stash', state: { subcommand: 'pop' } }); |
| 135 | + case Commands.GitCommandsStashPush: |
| 136 | + return this.execute({ command: 'stash', state: { subcommand: 'push' } }); |
| 137 | + case Commands.GitCommandsStashRename: |
| 138 | + return this.execute({ command: 'stash', state: { subcommand: 'rename' } }); |
| 139 | + case Commands.GitCommandsStatus: |
| 140 | + return this.execute({ command: 'status' }); |
| 141 | + case Commands.GitCommandsSwitch: |
| 142 | + case Commands.GitCommandsCheckout: |
| 143 | + return this.execute({ command: 'switch' }); |
| 144 | + case Commands.GitCommandsTag: |
| 145 | + return this.execute({ command: 'tag' }); |
| 146 | + case Commands.GitCommandsTagCreate: |
| 147 | + return this.execute({ command: 'tag', state: { subcommand: 'create' } }); |
| 148 | + case Commands.GitCommandsTagDelete: |
| 149 | + return this.execute({ command: 'tag', state: { subcommand: 'delete' } }); |
| 150 | + case Commands.GitCommandsWorktree: |
| 151 | + return this.execute({ command: 'worktree' }); |
| 152 | + case Commands.GitCommandsWorktreeCreate: |
| 153 | + return this.execute({ command: 'worktree', state: { subcommand: 'create' } }); |
| 154 | + case Commands.GitCommandsWorktreeDelete: |
| 155 | + return this.execute({ command: 'worktree', state: { subcommand: 'delete' } }); |
| 156 | + case Commands.GitCommandsWorktreeOpen: |
| 157 | + return this.execute({ command: 'worktree', state: { subcommand: 'open' } }); |
| 158 | + |
| 159 | + case Commands.CopyWorkingChangesToWorktree: |
| 160 | + return this.execute({ |
| 161 | + command: 'worktree', |
| 162 | + state: { subcommand: 'copy-changes', changes: { type: 'working-tree' } }, |
| 163 | + }); |
| 164 | + |
| 165 | + default: |
| 166 | + return this.execute(args); |
| 167 | + } |
| 168 | + } |
| 169 | +} |
0 commit comments