Skip to content

Commit cdbc7cd

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feature/output_formatter
2 parents 9c70ce1 + a380707 commit cdbc7cd

6 files changed

Lines changed: 48 additions & 28 deletions

File tree

DEVELOP.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,17 @@ after asking a few questions like maintainer name, email etc.
7070

7171
$ vagrant up
7272

73+
PEP8 checks
74+
-----------
75+
76+
When you submit a PR, the changeset is checked for pep8 compliance using
77+
`pep8radius <https://github.com/hayd/pep8radius>`_. If you see a build failing because
78+
of these checks, install pep8radius and apply style fixes:
79+
80+
::
81+
82+
$ pip install pep8radius
83+
$ pep8radius --docformatter --diff # view a diff of proposed fixes
84+
$ pep8radius --docformatter --in-place # apply the fixes
85+
86+
Then commit and push the fixes.

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ $ sudo apt-get install mycli # Only on debian or ubuntu
4343

4444
Options:
4545
-h, --host TEXT Host address of the database.
46-
-P, --port TEXT Port number to use for connection. Honors
46+
-P, --port INTEGER Port number to use for connection. Honors
4747
$MYSQL_TCP_PORT
4848
-u, --user TEXT User name to connect to the database.
4949
-S, --socket TEXT The socket file to use for connection.
50-
-p, --password Force password prompt.
50+
-p, --password TEXT Password to connect to the database
5151
--pass TEXT Password to connect to the database
5252
--ssl-ca PATH CA file in PEM format
5353
--ssl-capath TEXT CA directory
@@ -58,18 +58,21 @@ $ sudo apt-get install mycli # Only on debian or ubuntu
5858
against hostname used when connecting. This
5959
option is disabled by default
6060
-v, --version Version of mycli.
61-
-D, --database TEXT Database to use.
61+
-D, --database TEXT Database to use.
6262
-R, --prompt TEXT Prompt format (Default: "\t \u@\h:\d> ")
6363
-l, --logfile FILENAME Log every query and its results to a file.
6464
--defaults-group-suffix TEXT Read config group with the specified suffix.
6565
--defaults-file PATH Only read default options from the given file
66+
--myclirc PATH Location of myclirc file.
6667
--auto-vertical-output Automatically switch to vertical output mode
6768
if the result is wider than the terminal
6869
width.
6970
-t, --table Display batch output in table format.
71+
--csv Display batch output in CSV format.
7072
--warn / --no-warn Warn before running a destructive query.
7173
--local-infile BOOLEAN Enable/disable LOAD DATA LOCAL INFILE.
7274
--login-path TEXT Read this path from the login file.
75+
-e, --execute TEXT Execute query to the database.
7376
--help Show this message and exit.
7477

7578
### Examples

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Features:
77
* Add ability to specify alternative myclirc file. (Thanks: [Dick Marinus]).
88
* Add new display formats for pretty printing query results. (Thanks: [Amjith
99
Ramanujam], [Dick Marinus], [Thomas Roten]).
10+
* Add logic to shorten the default prompt if it becomes too long once generated. (Thanks: [John Sterling]).
1011

1112
Bug Fixes:
1213
----------
@@ -26,6 +27,7 @@ Internal Changes:
2627
Roten]).
2728
* Test mycli using pexpect/python-behave (Thanks: [Dick Marinus]).
2829
* Run pep8 checks in travis (Thanks: [Irina Truong]).
30+
* Remove temporary hack for sqlparse (Thanks: [Dick Marinus]).
2931

3032
1.9.0:
3133
======

mycli/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def emit(self, record):
6666
class MyCli(object):
6767

6868
default_prompt = '\\t \\u@\\h:\\d> '
69+
max_len_prompt = 45
6970
defaults_suffix = None
7071

7172
# In order of being loaded. Files lower in list override earlier ones.
@@ -452,7 +453,10 @@ def run_cli(self):
452453
print('Thanks to the contributor -', thanks_picker([author_file, sponsor_file]))
453454

454455
def prompt_tokens(cli):
455-
return [(Token.Prompt, self.get_prompt(self.prompt_format))]
456+
prompt = self.get_prompt(self.prompt_format)
457+
if self.prompt_format == self.default_prompt and len(prompt) > self.max_len_prompt:
458+
prompt = self.get_prompt('\\d> ')
459+
return [(Token.Prompt, prompt)]
456460

457461
def get_continuation_tokens(cli, width):
458462
continuation_prompt = self.get_prompt(self.prompt_continuation_format)

mycli/packages/completion_engine.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,28 @@ def suggest_type(full_text, text_before_cursor):
2828

2929
identifier = None
3030

31-
# This is a temporary hack; the exception handling
32-
# here should be removed once sqlparse has been fixed
33-
try:
34-
# If we've partially typed a word then word_before_cursor won't be an empty
35-
# string. In that case we want to remove the partially typed string before
36-
# sending it to the sqlparser. Otherwise the last token will always be the
37-
# partially typed string which renders the smart completion useless because
38-
# it will always return the list of keywords as completion.
39-
if word_before_cursor:
40-
if word_before_cursor[-1] == '(' or word_before_cursor[0] == '\\':
41-
parsed = sqlparse.parse(text_before_cursor)
42-
else:
43-
parsed = sqlparse.parse(
44-
text_before_cursor[:-len(word_before_cursor)])
31+
# If we've partially typed a word then word_before_cursor won't be an empty
32+
# string. In that case we want to remove the partially typed string before
33+
# sending it to the sqlparser. Otherwise the last token will always be the
34+
# partially typed string which renders the smart completion useless because
35+
# it will always return the list of keywords as completion.
36+
if word_before_cursor:
37+
if word_before_cursor.endswith(
38+
'(') or word_before_cursor.startswith('\\'):
39+
parsed = sqlparse.parse(text_before_cursor)
40+
else:
41+
parsed = sqlparse.parse(
42+
text_before_cursor[:-len(word_before_cursor)])
4543

46-
# word_before_cursor may include a schema qualification, like
47-
# "schema_name.partial_name" or "schema_name.", so parse it
48-
# separately
49-
p = sqlparse.parse(word_before_cursor)[0]
44+
# word_before_cursor may include a schema qualification, like
45+
# "schema_name.partial_name" or "schema_name.", so parse it
46+
# separately
47+
p = sqlparse.parse(word_before_cursor)[0]
5048

51-
if p.tokens and isinstance(p.tokens[0], Identifier):
52-
identifier = p.tokens[0]
53-
else:
54-
parsed = sqlparse.parse(text_before_cursor)
55-
except (TypeError, AttributeError):
56-
return []
49+
if p.tokens and isinstance(p.tokens[0], Identifier):
50+
identifier = p.tokens[0]
51+
else:
52+
parsed = sqlparse.parse(text_before_cursor)
5753

5854
if len(parsed) > 1:
5955
# Multiple statements being edited -- isolate the current one by

release.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def checklist(questions):
101101

102102
checks = ['Have you created the debian package?',
103103
'Have you updated the AUTHORS file?',
104+
'Have you updated the `Usage` section of the README?',
104105
]
105106
checklist(checks)
106107

0 commit comments

Comments
 (0)