Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
4be703cd
Commit
4be703cd
authored
8 years ago
by
Todd Gamblin
Browse files
Options
Downloads
Patches
Plain Diff
Allow common args to be written the same way regular args are.
parent
8f21332f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/spack/spack/cmd/common/arguments.py
+19
-49
19 additions, 49 deletions
lib/spack/spack/cmd/common/arguments.py
lib/spack/spack/util/pattern.py
+6
-0
6 additions, 0 deletions
lib/spack/spack/util/pattern.py
with
25 additions
and
49 deletions
lib/spack/spack/cmd/common/arguments.py
+
19
−
49
View file @
4be703cd
...
...
@@ -27,7 +27,7 @@
import
spack.store
import
spack.modules
from
spack.util.pattern
import
Bunch
from
spack.util.pattern
import
Args
__all__
=
[
'
add_common_arguments
'
]
_arguments
=
{}
...
...
@@ -60,56 +60,26 @@ def __call__(self, parser, namespace, values, option_string=None):
specs
=
[
x
for
x
in
specs
if
x
.
satisfies
(
values
,
strict
=
True
)]
namespace
.
specs
=
specs
parms
=
Bunch
(
flags
=
(
'
constraint
'
,),
kwargs
=
{
'
nargs
'
:
'
*
'
,
'
help
'
:
'
Constraint to select a subset of installed packages
'
,
'
action
'
:
ConstraintAction
})
_arguments
[
'
constraint
'
]
=
parms
_arguments
[
'
constraint
'
]
=
Args
(
'
constraint
'
,
nargs
=
'
*
'
,
action
=
ConstraintAction
,
help
=
'
Constraint to select a subset of installed packages
'
)
parms
=
Bunch
(
flags
=
(
'
-m
'
,
'
--module-type
'
),
kwargs
=
{
'
help
'
:
'
Type of module files
'
,
'
default
'
:
'
tcl
'
,
'
choices
'
:
spack
.
modules
.
module_types
})
_arguments
[
'
module_type
'
]
=
parms
_arguments
[
'
module_type
'
]
=
Args
(
'
-m
'
,
'
--module-type
'
,
help
=
'
Type of module files
'
,
default
=
'
tcl
'
,
choices
=
spack
.
modules
.
module_types
)
parms
=
Bunch
(
flags
=
(
'
-y
'
,
'
--yes-to-all
'
),
kwargs
=
{
'
action
'
:
'
store_true
'
,
'
dest
'
:
'
yes_to_all
'
,
'
help
'
:
'
Assume
"
yes
"
is the answer to every confirmation request.
'
})
_arguments
[
'
yes_to_all
'
]
=
parms
_arguments
[
'
yes_to_all
'
]
=
Args
(
'
-y
'
,
'
--yes-to-all
'
,
action
=
'
store_true
'
,
dest
=
'
yes_to_all
'
,
help
=
'
Assume
"
yes
"
is the answer to every confirmation request.
'
)
parms
=
Bunch
(
flags
=
(
'
-r
'
,
'
--dependencies
'
),
kwargs
=
{
'
action
'
:
'
store_true
'
,
'
dest
'
:
'
recurse_dependencies
'
,
'
help
'
:
'
Recursively traverse spec dependencies
'
})
_arguments
[
'
recurse_dependencies
'
]
=
parms
_arguments
[
'
recurse_dependencies
'
]
=
Args
(
'
-r
'
,
'
--dependencies
'
,
action
=
'
store_true
'
,
dest
=
'
recurse_dependencies
'
,
help
=
'
Recursively traverse spec dependencies
'
)
parms
=
Bunch
(
flags
=
(
'
--clean
'
,),
kwargs
=
{
'
action
'
:
'
store_false
'
,
'
dest
'
:
'
dirty
'
,
'
help
'
:
'
Clean environment before installing package.
'
})
_arguments
[
'
clean
'
]
=
parms
_arguments
[
'
clean
'
]
=
Args
(
'
--clean
'
,
action
=
'
store_false
'
,
dest
=
'
dirty
'
,
help
=
'
Clean environment before installing package.
'
)
parms
=
Bunch
(
flags
=
(
'
--dirty
'
,),
kwargs
=
{
'
action
'
:
'
store_true
'
,
'
dest
'
:
'
dirty
'
,
'
help
'
:
'
Do NOT clean environment before installing.
'
})
_arguments
[
'
dirty
'
]
=
parms
_arguments
[
'
dirty
'
]
=
Args
(
'
--dirty
'
,
action
=
'
store_true
'
,
dest
=
'
dirty
'
,
help
=
'
Do NOT clean environment before installing.
'
)
This diff is collapsed.
Click to expand it.
lib/spack/spack/util/pattern.py
+
6
−
0
View file @
4be703cd
...
...
@@ -140,3 +140,9 @@ class Bunch(object):
def
__init__
(
self
,
**
kwargs
):
self
.
__dict__
.
update
(
kwargs
)
class
Args
(
Bunch
):
"""
Subclass of Bunch to write argparse args more naturally.
"""
def
__init__
(
self
,
*
flags
,
**
kwargs
):
super
(
Args
,
self
).
__init__
(
flags
=
tuple
(
flags
),
kwargs
=
kwargs
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment