Skip to content

Commit edbeb5e

Browse files
author
Jimmy Brisson
committed
Improve dm subcommand
1 parent d5ea5a5 commit edbeb5e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

mbed/mbed.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,10 +2691,12 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
26912691
dict(name=['-m', '--target'], help='Target used for compile for target MCU. Example: K64F, NUCLEO_F401RE, NRF51822...'),
26922692
dict(name=['--profile'], help=""),
26932693
dict(name='--build', help='Build directory. Default: build/'),
2694+
dict(name='--source', action='append', help='Source directory. Default: . (current dir)'),
26942695
help='device management supcommand',
26952696
hidden_aliases=['dev-mgmt', 'dm'],
26962697
description=("Manage Device with Palion"))
26972698
def dev_mgmt(toolchain=None, target=None, source=False, profile=False, build=False):
2699+
orig_path = getcwd()
26982700
program = Program(getcwd(), True)
26992701
program.check_requirements(True)
27002702
with cd(program.path):
@@ -2712,20 +2714,23 @@ def dev_mgmt(toolchain=None, target=None, source=False, profile=False, build=Fal
27122714
build_path = build
27132715
elif not build and target and toolchain:
27142716
build_path = os.path.join(
2715-
os.path.relpath(program.path, orig_path),
2716-
program.build_dir,
2717-
target.upper(),
2718-
toolchain.upper()
2719-
)
2717+
os.path.relpath(program.path, orig_path),
2718+
program.build_dir,
2719+
target.upper(),
2720+
toolchain.upper()
2721+
)
27202722
build_path = _safe_append_profile_to_build_path(build_path, profile)
27212723
else:
27222724
build_path = None
27232725

2726+
args = remainder
2727+
if args[0] in ('update', 'create'):
2728+
args += (['--toolchain', toolchain] if toolchain else [])
2729+
args += (['--mcu', target] if target else [])
2730+
args += (['--build', build_path] if build_path else [])
27242731
popen([python_cmd, '-u', script]
2725-
+ (['-t', toolchain] if toolchain else [])
2726-
+ (['-m', target] if target else [])
2727-
+ (['--build', build_path] if build_path else [])
2728-
+ remainder,
2732+
+ args
2733+
+ list(chain.from_iterable(zip(repeat('--source'), source or []))),
27292734
env=program.get_env())
27302735

27312736
# Export command

0 commit comments

Comments
 (0)