Skip to content

Commit 3c1b16b

Browse files
CopilotTB-1993
andcommitted
Revert to first solution: restore _alias_name instance variable
Co-authored-by: TB-1993 <109213741+TB-1993@users.noreply.github.com>
1 parent 7c167e7 commit 3c1b16b

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/xts_core/xts.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class XTS():
7777
_xts_config (dict, optional): Parsed XTS configuration data. Defaults to None.
7878
_command_sections (dict): Dictionary of command sections extracted from configuration.
7979
_plugins (list): List of plugin classes providing additional commands.
80+
_alias_name (str, optional): The alias name used to invoke the command. Defaults to None.
8081
"""
8182

8283
def __init__(self):
@@ -86,6 +87,7 @@ def __init__(self):
8687
self._xts_config = None
8788
self._command_sections = {}
8889
self._plugins = [XTSAllocatorClient]
90+
self._alias_name = None
8991

9092
@property
9193
def xts_config(self):
@@ -171,9 +173,7 @@ def _parse_first_arg(self):
171173
Direct .xts file usage from cwd or as the first argument is not supported.
172174
173175
Returns:
174-
tuple[str, list[str]]: A tuple containing (alias_name, remaining_args).
175-
alias_name: The alias name used to invoke the command.
176-
remaining_args: Remaining args starting with the command name, e.g. ["run", ...].
176+
list[str]: Remaining args starting with the command name, e.g. ["run", ...].
177177
"""
178178
first_arg_parser = XTSArgumentParser(prog='xts',
179179
add_help=False)
@@ -204,19 +204,20 @@ def _parse_first_arg(self):
204204

205205
# load xts config remove alias name from argv before parsing
206206
self.xts_config = resolved_xts_path
207+
self._alias_name = alias_name
207208

208-
return alias_name, remaining_args[1:]
209+
return remaining_args[1:]
209210

210211
def run(self):
211212
"""Run the XTS app.
212213
213214
Raises:
214215
SystemExit: Raised when unrecogised arguments are given.
215216
"""
216-
alias_name, args = self._parse_first_arg()
217+
args = self._parse_first_arg()
217218

218219
try:
219-
prog_name = f'xts {alias_name}'
220+
prog_name = f'xts {self._alias_name}' if self._alias_name else 'xts'
220221
yaml_runner = YamlRunner(
221222
self._command_sections,
222223
program=prog_name,

0 commit comments

Comments
 (0)