提交 0ff7ae70 编写于 作者: W wuzewu

fix command-line bug

上级 28f7b25b
......@@ -38,12 +38,12 @@ class DownloadCommand(BaseCommand):
self.parser.print_help()
def exec(self, argv):
module_name = argv[1]
module_name = argv[0]
module_version = None if "==" not in module_name else module_name.split(
"==")[1]
module_name = module_name if "==" not in module_name else module_name.split(
"==")[0]
self.args = self.parser.parse_args(argv[2:])
self.args = self.parser.parse_args(argv[1:])
if not self.args.output_path:
self.args.output_path = "."
utils.check_path(self.args.output_path)
......
......@@ -38,20 +38,12 @@ class HubCommand(BaseCommand):
def exec(self, argv):
args = self.parser.parse_args(argv[1:2])
command_dict = {
'show': show.command.exec,
'run': run.command.exec,
'download': download.command.exec,
'help': help.command.exec,
'version': version.command.exec
}
if not args.command in command_dict:
if not args.command in BaseCommand.command_dict:
logger.critical("command %s not supported!" % args.command)
exit(1)
command = command_dict[args.command]
command(argv[2:])
command = BaseCommand.command_dict[args.command]
command.exec(argv[2:])
command = HubCommand.instance()
......
......@@ -34,7 +34,7 @@ class InstallCommand(BaseCommand):
self.parser.print_help()
def exec(self, argv):
module_name = argv[1]
module_name = argv[0]
module_version = None if "==" not in module_name else module_name.split(
"==")[1]
module_name = module_name if "==" not in module_name else module_name.split(
......
......@@ -19,6 +19,7 @@ from paddle_hub.tools.logger import logger
from paddle_hub.commands.base_command import BaseCommand
from paddle_hub.module.manager import default_manager
from paddle_hub.module.module import Module
import os
class ShowCommand(BaseCommand):
......@@ -30,11 +31,13 @@ class ShowCommand(BaseCommand):
self.description = "Show the specify module's info"
def exec(self, argv):
module_name = argv[1]
self.args = self.parser.parse_args(argv[2:])
module_name = argv[0]
cwd = os.getcwd()
module_dir = default_manager.search_module(module_name)
if not module_dir:
module_dir = os.path.join(cwd,
module_name) if not module_dir else module_dir
if not module_dir or not os.path.exists(module_dir):
return
module = Module(module_dir=module_dir)
......
......@@ -30,7 +30,7 @@ class UninstallCommand(BaseCommand):
self.description = "Uninstall the specify module from current environment."
def exec(self, argv):
module_name = argv[1]
module_name = argv[0]
default_manager.uninstall_module(module_name=module_name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册