From 48831fa850307d79b786076195ece1d387a4db5f Mon Sep 17 00:00:00 2001 From: nvbn Date: Fri, 17 Apr 2015 22:09:46 +0200 Subject: [PATCH] #1 Don't fuck twice --- setup.py | 2 +- thefuck/main.py | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index c7ed8500..2c0968eb 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup(name='thefuck', - version=1.4, + version=1.5, description="Magnificent app which corrects your previous console command", author='Vladimir Iakovlev', author_email='nvbn.rm@gmail.com', diff --git a/thefuck/main.py b/thefuck/main.py index 91d5974b..6b378417 100644 --- a/thefuck/main.py +++ b/thefuck/main.py @@ -74,13 +74,21 @@ def run_rule(rule, command, settings): print(new_command) +def is_second_run(command): + """It's second run of `fuck`?""" + return command.script.startswith('fuck') + + def main(): command = get_command(sys.argv) - user_dir = setup_user_dir() - settings = get_settings(user_dir) - rules = get_rules(user_dir, settings) - matched_rule = get_matched_rule(command, rules, settings) - if matched_rule: - run_rule(matched_rule, command, settings) + if is_second_run(command): + print("echo Can't fuck twice") else: - print('echo No fuck given') + user_dir = setup_user_dir() + settings = get_settings(user_dir) + rules = get_rules(user_dir, settings) + matched_rule = get_matched_rule(command, rules, settings) + if matched_rule: + run_rule(matched_rule, command, settings) + else: + print('echo No fuck given')