-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7b141f
commit 721b383
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python_sources() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Iterable | ||
|
||
from experimental.plugin.rules import rules as plugin_rules | ||
from pants.engine.rules import Rule | ||
from pants.engine.unions import UnionRule | ||
|
||
|
||
def rules() -> Iterable[Rule | UnionRule]: | ||
return (*plugin_rules(),) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Iterable | ||
from enum import Enum | ||
|
||
from pants.backend.project_info.peek import TargetDatas | ||
from pants.engine.console import Console | ||
from pants.engine.goal import Goal, GoalSubsystem, Outputting | ||
from pants.engine.rules import Get, Rule, collect_rules, goal_rule | ||
from pants.engine.target import UnexpandedTargets | ||
from pants.option.option_types import EnumOption, StrOption | ||
|
||
class PluginType(Enum): | ||
BUILTIN = "builtin" | ||
GOAL = "goal" | ||
LINTER = "linter" | ||
|
||
|
||
class PluginSubsystem(GoalSubsystem): | ||
name = "plugin-init" | ||
help = "???" | ||
|
||
plugin_name = StrOption( | ||
"--name", | ||
default=None, | ||
help="The name of the plugin to create.", | ||
) | ||
|
||
type = EnumOption( | ||
default=None, | ||
enum_type=PluginType, | ||
help="The type of plugin to create.", | ||
) | ||
|
||
|
||
class Plugin(Goal): | ||
subsystem_cls = PluginSubsystem | ||
environment_behavior = Goal.EnvironmentBehavior.LOCAL_ONLY | ||
|
||
|
||
@goal_rule | ||
async def plugin( | ||
console: Console, | ||
subsystem: PluginSubsystem, | ||
# targets: UnexpandedTargets, | ||
) -> Plugin: | ||
if not subsystem.type: | ||
console.input(f"What type of plugin do you want to create? {[p.value for p in PluginType]} ") | ||
|
||
return Plugin(exit_code=0) | ||
|
||
|
||
def rules() -> Iterable[Rule]: | ||
return collect_rules() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters