Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 56 additions & 24 deletions phabfive/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
T[0-9]+ Maniphest task

Options:
--log-level=<level> Set loglevel [default: INFO]
--log-level=LEVEL Set loglevel [default: INFO]
-h, --help Show this help message and exit
-V, --version Display the version number and exit
"""
Expand Down Expand Up @@ -65,10 +65,10 @@
-c, --clone Show clone url(s)

Uri Edit Options:
-n, --new_uri=<value> Change repository URI
-i, --io=<value> Adjust I/O behavior. Value: default, read, write, never
-d, --display=<value> Change display behavior. Value: default, always, hidden
-c, --cred=<value> Change credential for this URI. Ex. K2
-n, --new_uri=URI Change repository URI
-i, --io=VALUE Adjust I/O behavior. Value: default, read, write, never
-d, --display=VALUE Change display behavior. Value: default, always, hidden
-c, --cred=CREDENTIAL Change credential for this URI. Ex. K2
"""

sub_paste_args = """
Expand All @@ -86,8 +86,8 @@
-h, --help Show this help message and exit

Paste Create Options:
-t, --tags=<tags> ... Project name(s), ex. --tags=projectX,projectY,projectZ
-s, --subscribers=<sub> ... Subscribers - user, project, mailing list name. Ex --subscribers=user1,user2,user3
-t, --tags=TAGS ... Project name(s), ex. --tags=projectX,projectY,projectZ
-s, --subscribers=USERS ... Subscribers - user, project, mailing list name. Ex --subscribers=user1,user2,user3
"""

sub_user_args = """
Expand All @@ -110,7 +110,8 @@
Usage:
phabfive maniphest comment <ticket_id> <comment> [options]
phabfive maniphest show <ticket_id> [options]
phabfive maniphest create --with TEMPLATE [options]
phabfive maniphest create <title> [options]
phabfive maniphest create --with=TEMPLATE [options]
phabfive maniphest search <project_name> [options]

Options:
Expand All @@ -132,14 +133,29 @@

sub_maniphest_create_args = """
Usage:
phabfive maniphest create --with TEMPLATE [--dry-run] [options]
phabfive maniphest create <title> [--tag=TAG]... [--subscribe=USER]... [options]
phabfive maniphest create --with=TEMPLATE [options]

Arguments:
<title> Task title (for CLI mode)

Options:
--with=TEMPLATE Load task creation template from YAML file
--dry-run Does everything except commiting the tickets
-h, --help Show this help message and exit
--with=TEMPLATE Load task creation template from YAML file (bulk mode)
--description=TEXT Task description (optional)
--tag=TAG Project/workboard tag (repeatable, or use + for multiple)
--assign=USER Assignee username
--status=STATUS Task status (Open, Resolved, Wontfix, Invalid, Duplicate, Spite)
--priority=LEVEL Task priority (Unbreak, Triage, High, Normal, Low, Wish)
--subscribe=USER Subscriber username (repeatable, or use + for multiple)
--dry-run Preview without creating task
-h, --help Show this help message and exit

Examples:
# CLI mode - single task creation
phabfive maniphest create 'Fix login bug' --tag DevTeam --assign hholm --priority High
phabfive maniphest create 'New feature' --tag ProjectA --tag ProjectB --subscribe user1

# Template mode - bulk creation
phabfive maniphest create --with templates/task-create/project-setup.yaml
phabfive maniphest create --with templates/task-create/sprint-planning.yaml --dry-run
"""
Expand Down Expand Up @@ -601,21 +617,37 @@ def get_param(cli_key, yaml_params, yaml_key=None, default=None):
)

if sub_args.get("create"):
# This part is responsible for bulk creating several tickets at once

# Get config file from --with option
create_config = sub_args.get("--with")

if not create_config:
print("ERROR: Must specify --with TEMPLATE", file=sys.stderr)
# Check if template mode or CLI mode
if sub_args.get("--with"):
maniphest_app.create_from_config(
sub_args["--with"],
dry_run=sub_args.get("--dry-run", False),
)
elif sub_args.get("<title>"):
result = maniphest_app.create_task_cli(
title=sub_args["<title>"],
description=sub_args.get("--description"),
tags=sub_args.get("--tag"),
assignee=sub_args.get("--assign"),
status=sub_args.get("--status"),
priority=sub_args.get("--priority"),
subscribers=sub_args.get("--subscribe"),
dry_run=sub_args.get("--dry-run", False),
)
if result:
print(result["uri"])
# Print clickable tag URLs if any tags were added
if result.get("tag_slugs"):
for slug in result["tag_slugs"]:
print(f"{result['base_url']}/tag/{slug}/")
else:
print(
"ERROR: Must provide either a title or --with=TEMPLATE",
file=sys.stderr,
)
retcode = 1
return retcode

maniphest_app.create_from_config(
create_config,
dry_run=sub_args["--dry-run"],
)

if sub_args.get("comment"):
result = maniphest_app.add_comment(
sub_args["<ticket_id>"],
Expand Down
Loading