Module: DevContext::Commands::Help

Included in:
DevContext::CLI
Defined in:
lib/dev_context/commands/help.rb

Instance Method Summary collapse

Instance Method Details

#cmd_help(topic = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dev_context/commands/help.rb', line 6

def cmd_help(topic = nil)
  topic ||= argv.first
  if topic
    resolution = resolve_command(topic)
    normalized = resolution.is_a?(Hash) ? resolution[:command] : resolution
    return 1 if normalized.nil?

    return cmd_help_topic(normalized)
  end

  out.puts <<~HELP
    dx - developer context manager

    Commands:
      dx active
      dx add PATH|URL ...
      dx activate CONTEXT|PATH|URL
      dx branches|br [CONTEXT|PATTERN]
      dx cd CONTEXT|PATH|URL
      dx checkout|co [-b] FEATURE [CONTEXT]
      dx clone URL [PATH]
      dx create NAME [PATH] [BRANCH]
      dx doctor|check
      dx deactivate CONTEXT
      dx diff [CONTEXT]
      dx find [--stashes|--branches|--paths] <pattern>
      dx find --all
      dx <pattern>  # shorthand for: dx find <pattern>
      dx help
      dx init [ruby|go|elixir]
      dx import
      dx version
      dx popd [CONTEXT|+N|-N]
      dx pushd [CONTEXT|PATH|URL|+N|-N]
      dx repos [PATTERN]
      dx remove CONTEXT|PATH
      dx stash [--list] [--all|-a] [PATTERN]
      dx stashes [--list] [PATTERN]
      dx status|wip
  HELP
  0
end

#cmd_help_topic(command) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/dev_context/commands/help.rb', line 49

def cmd_help_topic(command)
  text = case command
         when "status", "wip"
           "Usage: dx status [--all] [--dirty] [-b BRANCHPATTERN] [-p PATHPATTERN]\n       dx wip [--all] [--dirty] [-b BRANCHPATTERN] [-p PATHPATTERN]\n\nShow branch and git status for active contexts. Use --all for all known repos, --dirty to filter non-clean repos, and -b/-p to filter by branch/path."
         when "repos"
           "Usage: dx repos [-b BRANCHPATTERN] [-p PATHPATTERN] [PATTERN]\n\nList all known repos without git status details. PATTERN is shorthand for path filtering."
         when "stash"
           "Usage: dx stash [--list] [--all|-a] [PATTERN]\n\nShow stashes for the active top context by default. Use --all/-a to scan all known repos. Provide PATTERN to filter stash titles; use --list to print matching entries."
         when "stashes"
           "Usage: dx stashes [--list] [PATTERN]\n\nShow repos with stashes. Provide PATTERN to filter stash titles; use --list to print matching entries."
         when "find"
           "Usage: dx find [--stashes|--branches|--paths] <pattern>\n       dx find --all\n\nSearch stash titles, branches, and repo paths. Use --all to show likely-forgotten work."
         when "doctor", "check"
           "Usage: dx doctor\n       dx check\n\nRun environment and config diagnostics."
         when "init"
           "Usage: dx init [ruby|go|elixir]\n\nInitialize dx files. If IMPL is given, set DX_IMPL non-interactively."
         when "version"
           "Usage: dx version\n       dx --version\n       dx -V\n\nPrint the active dx implementation and version."
         when "add"
           "Usage: dx add [-c NAME] [-n] [-v] PATH|URL ..."
         when "clone"
           "Usage: dx clone [-c NAME] [-n] [-v] URL [PATH]"
         when "create"
           "Usage: dx create [-c NAME] [-n] [-v] NAME [PATH] [BRANCH]"
         when "activate", "cd"
           "Usage: dx #{command} CONTEXT|PATH|URL"
         when "pushd"
           "Usage: dx pushd [CONTEXT|PATH|URL|+N|-N]\n\nCONTEXT accepts exact or fuzzy-matched context names. PATH and URL resolve/create contexts. +N/-N select existing active-stack entries (+0 top/left, -0 bottom/right) and rotate that entry to top."
         when "popd"
           "Usage: dx popd [CONTEXT|+N|-N]\n\nWith no args, same as `dx popd +0`. CONTEXT accepts exact or fuzzy-matched context names. +N counts from top/left (+0 top), -N from bottom/right (-0 bottom)."
         when "import"
           "Usage: dx import\n\nImport shell dirstack into dx active_stack (deduped by absolute path) and emit shell sync script."
         when "remove"
           "Usage: dx remove CONTEXT|PATH"
         when "diff"
           "Usage: dx diff [CONTEXT]"
         when "branches", "br"
           "Usage: dx branches|br [CONTEXT|PATTERN]\n\nWith a context, list git branches in that repo. With PATTERN, find repos whose current branch matches."
         when "checkout", "co"
           "Usage: dx checkout|co [-b] FEATURE [CONTEXT]"
         else
           "Usage: dx #{command}"
         end
  out.puts(text)
  0
end