Skip to content

Commit fff68d1

Browse files
author
gau1991
committed
Merge branch 'python'
2 parents a08e72e + 6d4b103 commit fff68d1

File tree

8 files changed

+221
-87
lines changed

8 files changed

+221
-87
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ script:
6464
- sudo ee site create site12.in --wpfc --wpsubdomain
6565
- sudo ee site create site12.net --wpfc --wpsubdomain
6666

67-
- sudo ee debug
68-
- sudo ee debug --stop
67+
- sudo ee debug --all
68+
- sudo ee debug --all=off
6969
- sudo ee debug site12.net
70-
- sudo ee debug site12.net --stop
70+
- sudo ee debug site12.net --all=off
7171
- sudo ee site create 1.com --html
7272
- sudo ee site create 2.com --php
7373
- sudo ee site create 3.com --mysql

config/bash_completion.d/ee_auto.rc

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _ee_complete()
2929
# IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE
3030
"debug")
3131
COMPREPLY=( $(compgen \
32-
-W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --start --nginx --php --fpm --mysql -i --interactive --stop " \
32+
-W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql -i --interactive --all --nginx=off --php=off --fpm=off --mysql=off --all=off " \
3333
-- $cur) )
3434
;;
3535

@@ -59,7 +59,7 @@ _ee_complete()
5959

6060
"log")
6161
COMPREPLY=( $(compgen \
62-
-W "--mysql --php --nginx --all" \
62+
-W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --mysql --php --nginx --all" \
6363
-- $cur) )
6464
;;
6565

@@ -110,13 +110,22 @@ _ee_complete()
110110
esac
111111

112112
if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]); then
113-
retlist="--start --stop --wp --rewrite -i"
113+
retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off"
114114
ret="${retlist[@]/$prev}"
115115
COMPREPLY=( $(compgen \
116116
-W "$(echo $ret)" \
117117
-- $cur) )
118118
fi
119119

120+
if [ ${COMP_WORDS[1]} == "log" ] && ([ "$prev" != "--access" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]); then
121+
retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off"
122+
ret="${retlist[@]/$prev}"
123+
COMPREPLY=( $(compgen \
124+
-W "$(echo $ret)" \
125+
-- $cur) )
126+
fi
127+
128+
120129
elif [ $COMP_CWORD -eq 4 ]; then
121130
case "$mprev" in
122131
# HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE
@@ -145,9 +154,16 @@ _ee_complete()
145154

146155
case "$prev" in
147156
"--wp" | "--wpsubdir" | "--wpsubdomain")
148-
COMPREPLY=( $(compgen \
149-
-W "--w3tc --wpfc --wpsc" \
150-
-- $cur) )
157+
if [ ${COMP_WORDS[1]} != "debug" ]; then
158+
retlist="--w3tc --wpfc --wpsc"
159+
else
160+
retlist="--wp=off --rewrite --rewrite=off -i --interactive"
161+
fi
162+
163+
ret="${retlist[@]/$prev}"
164+
COMPREPLY=( $(compgen \
165+
-W "$(echo $ret)" \
166+
-- $cur) )
151167
;;
152168

153169
"--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot")

ee/cli/ext/ee_outputhandler.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Based on https://github.com/datafolklabs/cement/issues/295
2+
# To avoid encoding releated error,we defined our custom output handler
3+
# I hope we will remove this when we upgarde to Cement 2.6 (Not released yet)
4+
import os
5+
from cement.utils import fs
6+
from cement.ext.ext_mustache import MustacheOutputHandler
7+
8+
9+
class EEOutputHandler(MustacheOutputHandler):
10+
class Meta:
11+
label = 'ee_output_handler'
12+
13+
def _load_template_from_file(self, path):
14+
for templ_dir in self.app._meta.template_dirs:
15+
full_path = fs.abspath(os.path.join(templ_dir, path))
16+
if os.path.exists(full_path):
17+
self.app.log.debug('loading template file %s' % full_path)
18+
return open(full_path, encoding='utf-8', mode='r').read()
19+
else:
20+
continue

ee/cli/main.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
from cement.core import foundation
1414
from cement.utils.misc import init_defaults
1515
from cement.core.exc import FrameworkError, CaughtSignal
16-
from cement.utils import fs
17-
from cement.ext.ext_mustache import MustacheOutputHandler
16+
from cement.ext.ext_argparse import ArgParseArgumentHandler
1817
from ee.core import exc
19-
18+
from ee.cli.ext.ee_outputhandler import EEOutputHandler
2019

2120
# Application default. Should update config/ee.conf to reflect any
2221
# changes, or additions here.
@@ -31,22 +30,12 @@
3130
# External templates (generally, do not ship with application code)
3231
defaults['ee']['template_dir'] = '/var/lib/ee/templates'
3332

34-
35-
# Based on https://github.com/datafolklabs/cement/issues/295
36-
# To avoid encoding releated error,we defined our custom output handler
37-
# I hope we will remove this when we upgarde to Cement 2.6 (Not released yet)
38-
class EEOutputHandler(MustacheOutputHandler):
33+
class EEArgHandler(ArgParseArgumentHandler):
3934
class Meta:
40-
label = 'ee_output_handler'
35+
label = 'ee_args_handler'
4136

42-
def _load_template_from_file(self, path):
43-
for templ_dir in self.app._meta.template_dirs:
44-
full_path = fs.abspath(os.path.join(templ_dir, path))
45-
if os.path.exists(full_path):
46-
self.app.log.debug('loading template file %s' % full_path)
47-
return open(full_path, encoding='utf-8', mode='r').read()
48-
else:
49-
continue
37+
def error(self, message):
38+
super(EEArgHandler, self).error("unknown args")
5039

5140

5241
class EEApp(foundation.CementApp):
@@ -72,6 +61,8 @@ class Meta:
7261
# default output handler
7362
output_handler = EEOutputHandler
7463

64+
arg_handler = EEArgHandler
65+
7566
debug = TOGGLE_DEBUG
7667

7768

0 commit comments

Comments
 (0)