cmds.projects.BaseCmdPkgRelations: Support spaces as delimiter

Some options to the pkg-xxx commands, like flavour, --subsections and --ignore understand a comma as delimiter if multiple option values are specified. The comma character is not very friendly to use in $(call ...) macros, though, so support spaces and pipe characters as well.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-17 13:34:53 +02:00
commit 37d5bcddd4
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -1,5 +1,7 @@
from __future__ import annotations from __future__ import annotations
import re
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from .Cmd import Cmd, Parent from .Cmd import Cmd, Parent
@ -11,23 +13,27 @@ if TYPE_CHECKING:
class BaseCmdPkgRelations(Cmd): class BaseCmdPkgRelations(Cmd):
arg_sep = r'[,\s|]'
def pkg_relations(self, rel_type: str, args: Namespace) -> str: def pkg_relations(self, rel_type: str, args: Namespace) -> str:
return args.delimiter.join( return args.delimiter.join(
pkg_relations_list( pkg_relations_list(
self.app, self.app,
rel_type = rel_type, rel_type = rel_type,
flavours = args.flavours.split(','), flavours = re.split(self.arg_sep, args.flavours),
seed_pkgs = args.modules, seed_pkgs = args.modules,
subsections = None subsections = (
if args.subsections is None else args.subsections.split(','), None if args.subsections is None else
re.split(self.arg_sep, args.subsections)
),
no_subpackages = args.no_subpackages, no_subpackages = args.no_subpackages,
dont_strip_revision = args.dont_strip_revision, dont_strip_revision = args.dont_strip_revision,
expand_semver_revision_range = args.expand_semver_revision_range, expand_semver_revision_range = args.expand_semver_revision_range,
syntax = VersionSyntax[args.syntax.replace('-', '_')], syntax = VersionSyntax[args.syntax.replace('-', '_')],
recursive = args.recursive, recursive = args.recursive,
dont_expand_version_macros = args.dont_expand_version_macros, dont_expand_version_macros = args.dont_expand_version_macros,
ignore = set(args.ignore.split(',')), ignore = set(re.split(self.arg_sep, args.ignore)),
quote = args.quote, quote = args.quote,
skip_excluded = args.skip_excluded, skip_excluded = args.skip_excluded,
hide_self = args.hide_self, hide_self = args.hide_self,
@ -49,7 +55,7 @@ class BaseCmdPkgRelations(Cmd):
'--subsections', '--subsections',
nargs = '?', nargs = '?',
default = None, default = None,
help = 'Subsections to consider, comma-separated', help = 'Subsections to consider, separated by comma or whitespace',
) )
parser.add_argument( parser.add_argument(
'-d', '-d',
@ -59,7 +65,9 @@ class BaseCmdPkgRelations(Cmd):
help = 'Output words delimiter' help = 'Output words delimiter'
) )
parser.add_argument( parser.add_argument(
'flavours', help = 'Dependency flavours (run, build, devel, release)' 'flavours',
help = 'Dependency flavours (run, build, devel, release), '
'separated by comma or whitespace'
) )
parser.add_argument('modules', nargs = '*', help = 'Modules') parser.add_argument('modules', nargs = '*', help = 'Modules')
parser.add_argument( parser.add_argument(