Skip to content

Commit

Permalink
start fixing autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
stepler committed Jun 22, 2012
1 parent 54f9ecb commit de80fbb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
10 changes: 5 additions & 5 deletions argparser.py
Expand Up @@ -264,7 +264,7 @@ def printAutocomplete(self):

# печатаем корневые команды
if self.CMD is None:
self.printGrid(CMD_LIST)
self.printGrid(self.CMD_LIST)

# работа с корневыми командами
elif not self.INP:
Expand All @@ -282,12 +282,12 @@ def printAutocomplete(self):
else:

# фильтруем аргументы которые еще не ввели
if self.CMD_ARGS.has_key(PREV_LAST_VAL) or self.CMD_FLAGS.has_key(LAST_VAL) :
printGrid([item for item in ARGS_FLAGS_LIST if item not in INP])
# if PREV_LAST_VAL in ARGS_FLAGS_LIST or LAST_VAL in ARGS_FLAGS_LIST: # self.CMD_ARGS.has_key(PREV_LAST_VAL) or self.CMD_FLAGS.has_key(LAST_VAL) :
self.printGrid([item for item in ARGS_FLAGS_LIST if item not in self.INP])

# автозаполнение для неполной команды
elif not self.CMD_ARGS.has_key(PREV_LAST_VAL):
self.printGrid([item for item in ARGS_FLAGS_LIST if item not in INP and item.startswith(LAST_VAL)])
self.printGrid([item for item in ARGS_FLAGS_LIST if item not in self.INP and item.startswith(LAST_VAL)])

# обработка аргумента
else:
Expand Down Expand Up @@ -330,4 +330,4 @@ def printHelp(self):
if self.CMD_FLAGS:
out.printLine("Available flags:")
for flag in self.CMD_FLAGS:
out.printLine("%s : %s" % (flag.rjust(tab, " "), self.CMD_FLAGS[flag]['help']))
out.printLine("%s : %s" % (flag.rjust(tab, " "), self.CMD_FLAGS[flag]['help']))
2 changes: 1 addition & 1 deletion bash_completion/geeknote
Expand Up @@ -5,7 +5,7 @@ _geeknote_command()

SAVE_IFS=$IFS
IFS=" "
args="${COMP_WORDS[*]}"
args="${COMP_WORDS[*]:1}"
IFS=$SAVE_IFS

COMPREPLY=( $(compgen -W "`geeknote autocomplete ${args}`" -- ${cur}) )
Expand Down
19 changes: 11 additions & 8 deletions geeknote.py
Expand Up @@ -5,6 +5,15 @@
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.append( os.path.join(PROJECT_ROOT, 'lib') )

import config

try:
if not os.path.exists(config.APP_DIR):
os.mkdir(config.APP_DIR)
except Exception, e:
logging.error("Can not create application dirictory.")
tools.exit()

import hashlib
import binascii
import time
Expand All @@ -21,7 +30,7 @@
import signal

import out
import config

from argparser import argparser
from oauth import GeekNoteAuth
from storage import Storage
Expand All @@ -30,12 +39,7 @@
from log import logging


try:
if not os.path.exists(config.APP_DIR):
os.mkdir(config.APP_DIR)
except Exception, e:
logging.error("Can not create application dirictory.")
tools.exit()


def GeekNoneDBConnectOnly(func):
def wrapper(*args, **kwargs):
Expand Down Expand Up @@ -656,7 +660,6 @@ def modifyArgsByStdinStream():


def main():

# if terminal
if sys.stdin.isatty():
sys_argv = sys.argv[1:]
Expand Down

0 comments on commit de80fbb

Please sign in to comment.