Skip to content

Commit

Permalink
Remove the goto help message from command d
Browse files Browse the repository at this point in the history
  • Loading branch information
joowani committed May 3, 2016
1 parent 5ed5d45 commit ebd5526
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 21 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ Technical Notes
of ``e``

- ``dtags edit`` uses environment variable **$EDITOR**
- ``d`` prefers tags over subdirectories if there is a name conflict
- To go to the subdirectory put a ``/`` after the directory name
- ``d`` requires ``grep``, ``cut``, ``seq`` and ``/dev/null``
- ``d`` expects ``~/.dtags/mapping`` to be correctly formatted:

Expand Down
2 changes: 0 additions & 2 deletions dtags/commands/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
ARG_ERR = '%sInvalid argument: %s\n'
CHOICE = '%s: %s\n'
DEST_ERR = '%sInvalid destination: %s\n'
GOTO_MSG = 'Going to %s\n'
INDEX_ERR = 'Index out of range: %s\n'
INPUT_ERR = 'Invalid input: %s\n'
PROMPT = '\nSelect directory (1 - %s): '
Expand All @@ -35,7 +34,6 @@
ARG_ERR_TTY = '%sInvalid argument: ' + style.bad('%s\n', tty=tty)
CHOICE_TTY = style.msg('%s: ', tty=tty) + style.path('%s\n', tty=tty)
DEST_ERR_TTY = '%sInvalid destination: ' + style.bad('%s\n', tty=tty)
GOTO_MSG_TTY = style.msg('Going to ', tty=tty) + style.path('%s\n', tty=tty)
INDEX_ERR_TTY = 'Index out of range: ' + style.bad('%s\n', tty=tty)
INPUT_ERR_TTY = 'Invalid input: ' + style.bad('%s\n', tty=tty)
PROMPT_TTY = style.msg('\nSelect directory (1 - %s): ', tty=tty)
3 changes: 1 addition & 2 deletions dtags/commands/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def _clean(args):
save_mapping(mapping)
finish('Cleaned the following entries:\n' + excluded)
else:
save_mapping(mapping)
finish('Nothing to clean')


Expand Down Expand Up @@ -182,14 +183,12 @@ def _shell(args):
version=VERSION,
usage=directory.USAGE,
description=directory.DESCRIPTION,
goto_msg_tty=directory.GOTO_MSG_TTY,
arg_err_tty=directory.ARG_ERR_TTY,
dest_err_tty=directory.DEST_ERR_TTY,
input_err_tty=directory.INPUT_ERR_TTY,
index_err_tty=directory.INDEX_ERR_TTY,
prompt_tty=directory.PROMPT_TTY,
choice_tty=directory.CHOICE_TTY,
goto_msg=directory.GOTO_MSG,
arg_err=directory.ARG_ERR,
dest_err=directory.DEST_ERR,
input_err=directory.INPUT_ERR,
Expand Down
10 changes: 6 additions & 4 deletions dtags/shells/bash.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
CONFIGURATION = """
unalias d &> /dev/null
d() {{
declare _dtags_usage="{usage}"
declare _dtags_version="{version}"
declare _dtags_description="{description}"
if [[ -t 1 ]]
then
declare _dtags_goto_msg="{goto_msg_tty}"
declare _dtags_arg_err="{arg_err_tty}"
declare _dtags_dest_err="{dest_err_tty}"
declare _dtags_input_err="{input_err_tty}"
declare _dtags_idx_err="{index_err_tty}"
declare _dtags_prompt="{prompt_tty}"
declare _dtags_choice="{choice_tty}"
else
declare _dtags_goto_msg="{goto_msg}"
declare _dtags_arg_err="{arg_err}"
declare _dtags_dest_err="{dest_err}"
declare _dtags_input_err="{input_err}"
Expand All @@ -23,7 +23,6 @@
fi
if [[ $# -lt 1 ]]
then
printf "$_dtags_goto_msg" "$HOME"
cd $HOME
return 0
elif [[ $1 = --help ]]
Expand All @@ -34,6 +33,10 @@
then
printf "Version $_dtags_version\n"
return 0
elif [[ $1 = - ]]
then
cd "$OLDPWD"
return 0
elif [[ $1 = -* ]]
then
printf "$_dtags_arg_err" "$_dtags_usage" "$1"
Expand Down Expand Up @@ -82,7 +85,6 @@
fi
if [[ -d $_dtags_dir ]]
then
printf "$_dtags_goto_msg" "$_dtags_dir"
cd "$_dtags_dir"
return 0
else
Expand Down
7 changes: 3 additions & 4 deletions dtags/shells/fish.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
set _dtags_version "{version}"
set _dtags_description "{description}"
if isatty 1
set _dtags_goto_msg "{goto_msg_tty}"
set _dtags_arg_err "{arg_err_tty}"
set _dtags_dest_err "{dest_err_tty}"
set _dtags_input_err "{input_err_tty}"
set _dtags_idx_err "{index_err_tty}"
set _dtags_choice "{choice_tty}"
set -g _dtags_prompt "{prompt_tty}"
else
set _dtags_goto_msg "{goto_msg}"
set _dtags_arg_err "{arg_err}"
set _dtags_dest_err "{dest_err}"
set _dtags_input_err "{input_err}"
Expand All @@ -21,7 +19,6 @@
set -g _dtags_prompt "{prompt}"
end
if math "1 >" (count $argv) > /dev/null
printf "$_dtags_goto_msg" "$HOME"
cd $HOME
return 0
else if [ $argv[1] = "--help" ]
Expand All @@ -30,6 +27,9 @@
else if [ $argv[1] = "--version" ]
printf "Version %s\n" "$_dtags_version"
return 0
else if [ $argv[1] = "-" ]
cd "$OLDPWD"
return 0
else if echo "$argv[1]" | grep -q -E '^-' > /dev/null
printf "$_dtags_arg_err" "$_dtags_usage" "$argv[1]"
return 2
Expand Down Expand Up @@ -67,7 +67,6 @@
set _dtags_dir $_dtags_dirs[$_dtags_idx]
end
if test -d $_dtags_dir
printf "$_dtags_goto_msg" "$_dtags_dir"
cd $_dtags_dir
return 0
else
Expand Down
6 changes: 1 addition & 5 deletions dtags/shells/zsh.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
CONFIGURATION = """
unalias d &> /dev/null
function d() {{
declare _dtags_usage='{usage}'
declare _dtags_version='{version}'
declare _dtags_description='{description}'
if [[ -t 1 ]]
then
declare _dtags_goto_msg="{goto_msg_tty}"
declare _dtags_arg_err="{arg_err_tty}"
declare _dtags_dest_err="{dest_err_tty}"
declare _dtags_input_err="{input_err_tty}"
declare _dtags_idx_err="{index_err_tty}"
declare _dtags_prompt="{prompt_tty}"
declare _dtags_choice="{choice_tty}"
else
declare _dtags_goto_msg="{goto_msg}"
declare _dtags_arg_err="{arg_err}"
declare _dtags_dest_err="{dest_err}"
declare _dtags_input_err="{input_err}"
Expand All @@ -24,7 +23,6 @@
fi
if [[ $# -lt 1 ]]
then
printf "$_dtags_goto_msg" "$HOME"
cd $HOME
return 0
elif [[ $1 = --help ]]
Expand All @@ -37,7 +35,6 @@
return 0
elif [[ $1 = - ]]
then
printf "$_dtags_goto_msg" "$OLDPWD"
cd "$OLDPWD"
return 0
elif [[ $1 = -* ]]
Expand Down Expand Up @@ -90,7 +87,6 @@
fi
if [[ -d $_dtags_dir ]]
then
printf "$_dtags_goto_msg" "$_dtags_dir"
cd "$_dtags_dir"
return 0
else
Expand Down
2 changes: 1 addition & 1 deletion dtags/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '2.0.6'
VERSION = '2.0.7'
7 changes: 4 additions & 3 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ def test_d():

# Test changing directories
d_msg = 'Going to {loc}\n{loc}\n'
assert run('d; pwd') == d_msg.format(loc=home)
assert run('d home; pwd') == d_msg.format(loc=home)
assert run('d tmp; pwd') == d_msg.format(loc='/tmp')
assert home in run('d; pwd')
assert home in run('d home; pwd')
assert '/tmp' in run('d tmp; pwd')
assert home in run('d -; pwd')


@pytest.mark.fifth
Expand Down

0 comments on commit ebd5526

Please sign in to comment.