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
35 changes: 35 additions & 0 deletions Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ $ lcls --labels Bug --include-labels <9>
<8> Filter to issues carrying "Bug" or "Feature" (case-insensitive OR); all labels on each match are shown
<9> Explicit `--include-labels` is redundant when `--labels` is also present; both work together

In JSON mode, a project filter must match one project exactly. Partial project
matches are rejected on stderr instead of opening the text-mode selection menu.

==== View an Issue

Show full details for a single issue (title, description, and all comments):
Expand All @@ -260,6 +263,9 @@ $ lc issue view CRY-1234 -w <4>
<3> Open the issue in your browser instead of printing it
<4> Short form of `--web`

NOTE: JSON output cannot be combined with `--web`, because opening a browser
does not produce an issue value on stdout.

==== Assign one or more issues to yourself (take em!)

[source,sh]
Expand All @@ -286,6 +292,9 @@ $ lc issue assign CRY-1234 <4>
<3> Short form of `--status`
<4> Prompts for the assignee interactively

NOTE: In JSON mode, `--assignee` is required. An omitted assignee is an
interactive choice in text mode and is rejected on stderr in JSON mode.

==== Unassign one or more issues

This command clears the assignee from each listed issue. It accepts explicit
Expand Down Expand Up @@ -344,6 +353,11 @@ NOTE: `--yes` creates and self-assigns an issue without prompting. Add

TIP: When creating an issue, you can use the `--dev` (or `--develop`) option to immediately start development on the issue.

NOTE: JSON issue creation requires `--yes`, which supplies all required
fields without prompts. JSON mode does not support `--dev`; use the separate
`issue develop` command after creation. A project supplied with `--yes` must
match exactly; partial project searches are rejected before issue creation.

==== Develop an issue

Switches to the branch for the issue, creating the branch if it doesn't exist.
Expand All @@ -362,6 +376,10 @@ Requires the `gh` CLI to be installed and configured.
$ lc issue pr CRY-1234
----

NOTE: JSON `issue pr` requires both `--title` and `--description`. Without
those options the text command asks questions and JSON mode rejects the
invocation before checking out the branch.

==== Update an issue

All of the update options can work on multiple issues at a time.
Expand Down Expand Up @@ -411,6 +429,12 @@ the team has more than one matching state.
$ lc issue update --close --status Done --reason "These were closable" CRY-1234 CRY-2
----

For JSON issue updates, close and cancel operations require both `--status`
and `--reason`. Project moves also require an exact project match, and the
`-` editor sentinel is not accepted for JSON comment, description, or reason
inputs. These checks happen before the first issue mutation; text mode keeps
its prompts.

==== Move an issue to a different workflow state

Changes the workflow state of one or more issues. Prompts interactively when
Expand All @@ -428,6 +452,12 @@ $ lc issue status CRY-1234 -s Done -m "Wrapped up" <4>
<3> Move multiple issues at once — updates run concurrently
<4> Add a comment alongside the state change

NOTE: JSON `issue status` requires `--status`. The interactive state menu is
available in text mode only.

For `issue comment`, JSON mode requires `--comment` or `--body-file`; the
editor prompt used when neither is supplied remains a text-mode behavior.

==== Move issues to a project

Two modes: move specific issues by ID, or bulk-move an entire project's backlog.
Expand Down Expand Up @@ -491,6 +521,11 @@ $ lc profile delete manhattan
An explicit `--team`/`--project` on the command line always overrides the
active profile.

Profile and favorite mutations return one JSON result when `--output json` is
used. Project favorites and project updates require an exact project name or
ID, and require `--team` or an active profile when more than one team is
available. Text mode keeps its existing selection prompts.

Issue commands also accept a bare number (`lc issue develop 1234`) in
place of a full team-prefixed identifier - it's resolved via the active
profile's team, then favorited teams, then a prompt across every team you
Expand Down
24 changes: 22 additions & 2 deletions app/lib/linear_cli/cli/commands/issues/create.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ defmodule LinearCli.CLI.Commands.Issues.Create do
def issue_create(result, opts \\ [])

def issue_create(%{options: options, flags: flags}, opts) do
with :ok <- validate_no_take_develop(flags),
command_opts = Keyword.put(opts, :output, Map.get(options, :output, "text"))

with :ok <- validate_json_create(options, flags),
:ok <- validate_no_take_develop(flags),
:ok <- validate_body_file_exclusion(options, :description, "--description"),
{:ok, description} <- resolve_body_from_file(options, :description),
create_opts = [
Expand All @@ -41,7 +44,7 @@ defmodule LinearCli.CLI.Commands.Issues.Create do
yes: flags.yes
],
{:ok, issue} <- Creation.make_da_issue!(create_opts),
:ok <- maybe_take(issue, flags, opts) do
:ok <- maybe_take(issue, flags, command_opts) do
Display.show(issue, %{output: options.output})
if flags.develop, do: run_develop(issue.id, opts), else: :ok
end
Expand All @@ -52,6 +55,23 @@ defmodule LinearCli.CLI.Commands.Issues.Create do

defp validate_no_take_develop(_flags), do: :ok

defp validate_json_create(options, flags) do
if Map.get(options, :output, "text") != "json" do
:ok
else
cond do
not Map.get(flags, :yes, false) ->
{:error, {:smells_bad, "JSON output requires --yes for issue create"}}

Map.get(flags, :develop, false) ->
{:error, {:smells_bad, "JSON output cannot be used with --dev"}}

true ->
:ok
end
end
end

defp maybe_take(_issue, %{no_take: true}, _opts), do: :ok

defp maybe_take(issue, %{yes: true}, opts) do
Expand Down
65 changes: 51 additions & 14 deletions app/lib/linear_cli/cli/commands/issues/development.ex