run: add -c|--cwd option

Fixes #343

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2017-12-10 06:06:29 +02:00
parent 8bfc1f77f3
commit 2ded6bf409
2 changed files with 8 additions and 4 deletions
+4
View File
@@ -118,6 +118,10 @@ def parse_args(argv=None):
'--file',
default=StateFile.DVCFILE_NAME,
help='Specify name of the state file')
run_parser.add_argument('-c',
'--cwd',
default=os.path.curdir,
help='Directory to run your command and place state file in')
run_parser.add_argument(
'command',
nargs=argparse.REMAINDER,
+4 -4
View File
@@ -24,7 +24,7 @@ class CmdRun(CmdBase):
Logger.error("Stage file {} already exists".format(self.parsed_args.file))
return 1
state = StateFile(fname=self.parsed_args.file,
state = StateFile(fname=os.path.join(self.parsed_args.cwd, self.parsed_args.file),
cmd=cmd,
out=self.parsed_args.out,
out_git=self.parsed_args.out_git,
@@ -44,9 +44,9 @@ class CmdRun(CmdBase):
@staticmethod
def update_state_file(settings, state):
Logger.debug('Update state file "{}"'.format(state.path))
state.out = StateFile.parse_deps_state(settings, state.out)
state.out_git = StateFile.parse_deps_state(settings, state.out_git)
state.deps = StateFile.parse_deps_state(settings, state.deps)
state.out = StateFile.parse_deps_state(settings, state.out, currdir=state.cwd)
state.out_git = StateFile.parse_deps_state(settings, state.out_git, currdir=state.cwd)
state.deps = StateFile.parse_deps_state(settings, state.deps, currdir=state.cwd)
state.save()
@staticmethod