Mercurial > libervia-backend
annotate misc/_jp @ 853:c2f6ada7858f
core (sqlite): automatic database update:
- new Updater class check database consistency (by calculating a hash on the .schema), and updates base if necessary
- database now has a version (1 for current, 0 will be for 0.3's database), for each change this version will be increased
- creation statements and update statements are in the form of dict of dict with tuples. There is a help text at the top of the module to explain how it works
- if we are on a development version, the updater try to update the database automaticaly (without deleting table or columns). The Updater.generateUpdateData method can be used to ease the creation of update data (i.e. the dictionary at the top, see the one for the key 1 for an example).
- if there is an inconsistency, an exception is raised, and a message indicate the SQL statements that should fix the situation.
- well... this is rather complicated, a KISS method would maybe have been better. The future will say if we need to simplify it :-/
- new DatabaseError exception
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 23 Feb 2014 23:30:32 +0100 |
parents | c328bcc4db71 |
children | 069ad98b360d |
rev | line source |
---|---|
818
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #compdef jp jp_dev |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # jp: a SAT command line tool |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 # This program is free software: you can redistribute it and/or modify |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # it under the terms of the GNU Affero General Public License as published by |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # the Free Software Foundation, either version 3 of the License, or |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # (at your option) any later version. |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # This program is distributed in the hope that it will be useful, |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # GNU Affero General Public License for more details. |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # You should have received a copy of the GNU Affero General Public License |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 #TODO: - caching (see _store_cache en _retrieve_cache) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 # - filtering imposibles arguments |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 # - arguments (jids, files) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 PYTHON='python2' |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 local optionals subcommands arguments |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 local context state state_descr line |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 typeset -A val_args |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 _jp() { |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 eval `/usr/bin/env $PYTHON 2> /dev/null <<- PYTHONEND |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 import re |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 from subprocess import check_output |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 # import sys |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 # words_raw="jp_dev " + ' '.join(sys.argv[1:]) # for debugging in a script |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 words_raw="$words" # $words is the command line currently completed |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 words_all = words_raw.split() |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 prog_name = words_all[0] |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 words_no_opt = [word for word in words_all if not word.startswith('-')] # command line without optional arguments |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 choices_cache = {} |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 ARG = r'[-a-z0-9_]' # charset accepted for an argument name |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 subcommands_re = re.compile(r"^ +{((?:" + ARG + r"+)(?:," + ARG + r"+)*)}", re.MULTILINE) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 optionals_re = re.compile(r"^ {2,}(--?" + ARG + r"+(?: [A-Z_0-9]+)?(?:, --" + ARG + r"+(?: [A-Z_0-9]+)?)?)\n? {2,}(.*(?:\n {4,}.*)*$)", re.MULTILINE) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 arguments_re = re.compile(r"^ {2,}([a-z_]" + ARG + r"*) {2,}(.*$)", re.MULTILINE) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 clean_re = re.compile(r"(?P<prefix_spaces>^ +)|(?P<double_spaces> {2,})|(?P<newline>\n)|(?P<quote>')|(?P<suffix_spaces> +$)", re.MULTILINE) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 def _clean(desc): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 def sub_clean(match): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 matched_dict = match.groupdict() |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 matched = {matched for matched in matched_dict if matched_dict[matched]} |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 if matched.intersection(('prefix_spaces', 'suffix_spaces')): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 return '' |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 elif matched.intersection(('double_spaces', 'newline')): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 return ' ' |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 elif matched.intersection(('quote',)): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 return r"'\''" |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 else: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 raise ValueError |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 return clean_re.sub(sub_clean, desc) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 def parse_help(jp_help): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 # parse the help returning subcommands, optionals arguments, and mandatory arguments |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 subcommands = subcommands_re.findall(jp_help) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 subcommands = {subcommand:"" for subcommand in subcommands[0].split(',')} if subcommands else {} |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 optionals = dict(optionals_re.findall(jp_help)) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 arguments = dict(arguments_re.findall(jp_help)) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 for subcommand in subcommands: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 subcommands[subcommand] = arguments.pop(subcommand, '') |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 return subcommands, optionals, arguments |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 def get_choice(opt_choice): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 choices = choices_cache.get(opt_choice) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 if choices is not None: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 return choices |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 if opt_choice == 'PROFILE': |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 profiles = check_output([prog_name, 'profile', 'list']) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 choices = ":profile:(%s)" % ' '.join(profiles.split('\n')) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 if choices: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 choices_cache[opt_choice] = choices |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 return choices |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 else: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 return "" |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 def construct_opt(opts, desc): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 # construct zsh's _arguments line for optional arguments |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 arg_lines = [] |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 for opt in opts.split(', '): |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 try: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 opt_name, opt_choice = opt.split() |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 except ValueError: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 # there is no argument |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 opt_name, opt_choice = opt, None |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 # arg_lines.append("'()%s[%s]%s'" % (opt_name+('=' if opt_name.startswith('--') else '+'), |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 arg_lines.append("'()%s[%s]%s'" % (opt_name, |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 _clean(desc), |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 "%s" % get_choice(opt_choice) if opt_choice else '' |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 )) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 return ' '.join(arg_lines) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 current_args = [] |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 while True: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 # parse jp's help recursively until words_no_opt doesn't correspond anymore to a subcommand |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 try: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 current_args.append(words_no_opt.pop(0)) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 jp_help = check_output(current_args + ['--help']) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 # print "jp_help (%s):\n%s\n\n---\n" % (' '.join(current_args), jp_help) # for debugging |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 subcommands, optionals, arguments = parse_help(jp_help) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 if words_no_opt[0] not in subcommands: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 break |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 except IndexError: |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 break |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 # now we fill the arrays so zsh can use them |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 env=[] |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 env.append("optionals=(%s)" % ' '.join(construct_opt(opt, desc) for opt, desc in optionals.items())) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 env.append("subcommands=(%s)" % ' '.join(["'%s[%s]'" % (subcommand, _clean(desc)) for subcommand, desc in subcommands.items()])) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 env.append("arguments=(%s)" % ' '.join(["'%s[%s]'" % (argument, _clean(desc)) for argument, desc in arguments.items()])) |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 print ";".join(env) # this line is for eval |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 PYTHONEND |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 ` |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 if [ -n "$optionals" ]; then |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 _values optional $optionals |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 fi |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 if [ -n "$subcommands" ]; then |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 _values subcommand $subcommands |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 fi |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 if [ -n "$arguments" ]; then |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 #_values argument $arguments |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 fi |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 } |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 |
c328bcc4db71
jp: zsh completion, first draft (added in a new /misc directory):
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 _jp "$@" |