Fossil: Check-in [5d66314586]

Fossil SCM

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Follow zsh guidelines for autocompletion script (https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide))
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | zsh-completion
Files: files | file ages | folders
SHA3-256:5d66314586fb326204597b9c8d9adcf1f0e97ba1ab841abf142f1ebcbb1bfcf0
User & Date: milouse 2018-12-05 09:01:14
Context
2018-12-05
09:01
Follow zsh guidelines for autocompletion script (https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide)) Leaf check-in: 5d66314586 user: milouse tags: zsh-completion
2018-12-04
16:43
Fix the completion for e.g. fossil uv command check-in: c519d8b754 user: milouse tags: zsh-completion
Changes

Changes to tools/fossil-autocomplete.zsh.

24
25
26
27
28
29
30
31

32
33
34
35

36
37
38
39
40
41
42
43
44
45
46
47
48
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126








#
# Package example:
#       install -Dm644 fossil-autocomplete.zsh /share/zsh/site-functions/_fossil
#
# ------------------------------------------------------------------------------

__fossil_subcommand_list () {
    fossil help $1 | sed -n "s/^  *fossil $1 \([^| []*\).*$/\1/p" | sed '/^$/d' | sort | uniq

}

__fossil_setting_list () {
    fossil settings | sed -n 's/^\([0-9a-z-]*\)\( *.*\)\?$/\1/p' | sed '/^$/d' | sort | uniq

}

__fossil_branches () {
    _arguments '*:fossil branches:($(fossil branch list | sed -n "s/^[ *] \(.*\)$/\1/p"))' && ret=0
}

__fossil_commands () {
    _arguments '*:fossil commands:($(fossil help -a))' && ret=0
}

_fossil () {
    local curcontext="$curcontext" state line expl ret=1
    typeset -A opt_args

    _arguments -C '(- *)--help[Print help information]' \
               '(--chdir)--chdir[Change to the named directory before processing any commands]' \
               '(--utc)--localtime[Override the timeline-utc option to explicitly use local time]' \
               '(--quiet)--quiet[Cause fossil to suppress various messages and progress indicators]' \
               '(--user --user-override)--user[Set the user name used with the repository]' \
               '(--localtime)--utc[Override the timeline-utc option to explicitly use UTC time]' \
               '1:command:->commands' \
               '*:argument:->args' && ret=0

    case $state in
        commands)
            __fossil_commands
            ;;
        args)
            local -a opts
            help_word=$words[2]
            [ "$help_word" = 'all' ] && help_word=$words[3]

            fossil help $help_word | sed -n '/^ \{2,3\}\(-[a-zA-Z]|\)\?--[a-z-]* .*$/{
                h # Keep pattern on hold
                :loop
                n # Advance one line
                /^ \{2,3\}\(-[a-zA-Z]|\)\?--[a-z-]* .*$/{
                    b print
                }
                /^$/{
                    b loop
                }
                /^[^ ]/{
                    b print
                }
                H # hold += nl + pattern
                b loop # Go to loop
                :print
                x # Swap hold/pattern
                /^  */!q
                s/\n */ /g # Replace nl by space characters
                # Then extract usefull values
                s/^ \{2,3\}\(\(-[a-zA-Z]|\)\?--[a-z-]*\) \([A-Z:-]*\)\? *\(.*\)$/\1:\4/
                s/^\(.*\)|\(.*\):\(.*\)$/\1:\3\n\2:\3/ # Format short flags
                p # Print pattern
                b loop # Go to loop
            }' | while read line; do
                opts+="$line"
            done
            _describe 'options' opts && ret=0
            unset opts

            local -a subcmds
            subcmds=($(__fossil_subcommand_list $words[2]))
            [ ${#subcmds} -gt 0 ] && _values 'subcommands' $subcmds && ret=0
            unset subcmds

            case $words[2] in
                all|help)
                    __fossil_commands
                    ;;
                merge|up*)
                    __fossil_branches
                    ;;
                branch)
                    [ ${#words} -gt 2 ] && [ "$words[3]" = 'info' ] && __fossil_branches

                    ;;
                'unset'|'set'*)
                    _arguments '*:fossil settings:($(__fossil_setting_list))' && ret=0
                    ;;
                add)
                    _arguments '*:extra files:($(fossil extra))' && ret=0
                    ;;
                *)
                    _arguments '*:files:_files' && ret=0
                    ;;
            esac
            ;;
    esac
}

_fossil















|
>



|
>



|



|



|
|

|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|

|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|



>
>
>
>
>
>
>
>
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# Package example:
#       install -Dm644 fossil-autocomplete.zsh /share/zsh/site-functions/_fossil
#
# ------------------------------------------------------------------------------

__fossil_subcommand_list () {
  fossil help $1 | sed -n "s/^  *fossil $1 \([^| []*\).*$/\1/p" | \
      sed '/^$/d' | sort | uniq
}

__fossil_setting_list () {
  fossil settings | sed -n 's/^\([0-9a-z-]*\)\( *.*\)\?$/\1/p' | \
      sed '/^$/d' | sort | uniq
}

__fossil_branches () {
  _arguments '*:fossil branches:($(fossil branch list | sed -n "s/^[ *] \(.*\)$/\1/p"))' && ret=0
}

__fossil_commands () {
  _arguments '*:fossil commands:($(fossil help -a))' && ret=0
}

_fossil () {
  local curcontext="$curcontext" state line expl ret=1
  typeset -A opt_args

  _arguments -C '(- *)--help[Print help information]' \
      '(--chdir)--chdir[Change to the named directory before processing any commands]' \
      '(--utc)--localtime[Override the timeline-utc option to explicitly use local time]' \
      '(--quiet)--quiet[Cause fossil to suppress various messages and progress indicators]' \
      '(--user --user-override)--user[Set the user name used with the repository]' \
      '(--localtime)--utc[Override the timeline-utc option to explicitly use UTC time]' \
      '1:command:->commands' \
      '*:argument:->args' && ret=0

  case $state in
    commands)
      __fossil_commands
      ;;
    args)
      local -a opts
      help_word=$words[2]
      [ "$help_word" = 'all' ] && help_word=$words[3]
      fossil help $help_word | \
          sed -n '/^ \{2,3\}\(-[a-zA-Z]|\)\?--[a-z-]* .*$/{
          h # Keep pattern on hold
          :loop
          n # Advance one line
          /^ \{2,3\}\(-[a-zA-Z]|\)\?--[a-z-]* .*$/{
              b print
          }
          /^$/{
              b loop
          }
          /^[^ ]/{
              b print
          }
          H # hold += nl + pattern
          b loop # Go to loop
          :print
          x # Swap hold/pattern
          /^  */!q
          s/\n */ /g # Replace nl by space characters
          # Then extract usefull values
          s/^ \{2,3\}\(\(-[a-zA-Z]|\)\?--[a-z-]*\) \([A-Z:-]*\)\? *\(.*\)$/\1:\4/
          s/^\(.*\)|\(.*\):\(.*\)$/\1:\3\n\2:\3/ # Format short flags
          p # Print pattern
          b loop # Go to loop
        }' | while read line; do
        opts+="$line"
      done
      _describe 'options' opts && ret=0
      unset opts

      local -a subcmds
      subcmds=($(__fossil_subcommand_list $words[2]))
      [ ${#subcmds} -gt 0 ] && _values 'subcommands' $subcmds && ret=0
      unset subcmds

      case $words[2] in
        all|help)
          __fossil_commands
          ;;
        merge|up*)
          __fossil_branches
          ;;
        branch)
          [ ${#words} -gt 2 ] && [ "$words[3]" = 'info' ] && \
              __fossil_branches
          ;;
        'unset'|'set'*)
          _arguments '*:fossil settings:($(__fossil_setting_list))' && ret=0
          ;;
        add)
          _arguments '*:extra files:($(fossil extra))' && ret=0
          ;;
        *)
          _arguments '*:files:_files' && ret=0
          ;;
      esac
      ;;
  esac
}

_fossil

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et