mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 01:28:56 +00:00
get_command() should work, --ifuckedup and --add_fix both allowed now, trouble with tests
This commit is contained in:
parent
65543c43bb
commit
082fff7467
@ -73,11 +73,11 @@ def check_args(settings, args, cmd):
|
|||||||
--ifuckedup requires relevent fix.
|
--ifuckedup requires relevent fix.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
options, leftovers = getopt.getopt(args, '', ['ifuckedup=', 'remove='])
|
options, leftovers = getopt.getopt(args, '', ['add_fix=', 'ifuckedup=', 'remove='])
|
||||||
|
|
||||||
for opt, val in options:
|
for opt, val in options:
|
||||||
try:
|
try:
|
||||||
if opt == '--ifuckedup':
|
if opt == '--ifuckedup' or opt == '--add_fix':
|
||||||
custom_fuckups.add_fuckup(cmd, val)
|
custom_fuckups.add_fuckup(cmd, val)
|
||||||
return True
|
return True
|
||||||
elif opt == '--remove':
|
elif opt == '--remove':
|
||||||
@ -91,26 +91,19 @@ def check_args(settings, args, cmd):
|
|||||||
|
|
||||||
|
|
||||||
def get_command(settings):
|
def get_command(settings):
|
||||||
"""Creates command from `args` and executes it."""
|
"""Retrieves previous command from ~/.bash_history ."""
|
||||||
|
|
||||||
# trying to use history to get recent calls instead of using the alias
|
# requires following in .bashrc
|
||||||
|
|
||||||
# - no need for alias with that ^^^
|
# shopt -s histappend
|
||||||
# - allows for command line args
|
# PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
|
||||||
|
|
||||||
shell_cmd = "bash -c -i 'history -r; history -p \!\!'"
|
shell_cmd = "bash -c -i 'history -r; history -p \!\!'"
|
||||||
event = Popen(shell_cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
|
event = Popen(shell_cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
|
||||||
|
|
||||||
output = event.communicate()
|
output = event.communicate()
|
||||||
|
|
||||||
args = output.strip()
|
script = output.strip()
|
||||||
|
|
||||||
# if six.PY2:
|
|
||||||
# script = ' '.join(arg.decode('utf-8') for arg in args[1:])
|
|
||||||
# else:
|
|
||||||
# script = ' '.join(args[1:])
|
|
||||||
|
|
||||||
script = args
|
|
||||||
|
|
||||||
if not script:
|
if not script:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user