Skip to content

Commit

Permalink
feat: add legend
Browse files Browse the repository at this point in the history
  • Loading branch information
jamacku committed Aug 14, 2024
1 parent 4c060f2 commit 811d990
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Options:
-c, --component [component] Issue component
-a, --assignee [assignee] Issue assignee
-d, --developer [developer] Issue developer
-l, --legend Print legend
-h, --help display help for command
```

Expand All @@ -82,7 +83,7 @@ Size all issues of the `curl` component:

```md
storypointer -c curl
# output:

JIRA Version: 9.12.10
5 issues are waiting to be sized and prioritized.

Expand Down
29 changes: 29 additions & 0 deletions src/legend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import chalk from 'chalk';
import { issueStatusSchema } from './schema/jira';

export function getLegend() {
return `
Issue Legend:
<TYPE> <ISSUE-KEY> - ${chalk.bold('<STATUS>')} - ${chalk.italic('<ASSIGNEE>')}
${chalk.italic('<ISSUE DESCRIPTION>')}
See more: ${chalk.italic.underline('<URL>')}
<TYPE>:
☑️ - Task
🐛 - Bug
🎁 - Story
⚡ - Epic
<STATUS>:
${issueStatusSchema.parse('New')}
${issueStatusSchema.parse('Planning')}
${issueStatusSchema.parse('In Progress')}
${issueStatusSchema.parse('Integration')}
${issueStatusSchema.parse('Release Pending')}
Example:
🐛 RHEL-1234 - ${chalk.bold(issueStatusSchema.parse('In Progress'))} - ${chalk.italic('Assignee')}
${chalk.italic('Add new feature to curl')}
See more: ${chalk.italic.underline('https://issues.redhat.com/browse/RHEL-1234')}`;
}
14 changes: 11 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import dotenv from 'dotenv';
import '@total-typescript/ts-reset';

import { Jira } from './jira';
import { getLegend } from './legend';
import { raise, tokenUnavailable } from './util';

import {
colorPrioritySchema,
colorSizeSchema,
Expand Down Expand Up @@ -41,20 +43,26 @@ const cli = async () => {
program
.option('-c, --component [component]', 'Issue component')
.option('-a, --assignee [assignee]', 'Issue assignee')
.option('-d, --developer [developer]', 'Issue developer');
.option('-d, --developer [developer]', 'Issue developer')
.option('-l, --legend', 'Print legend');

program.argument('[string]', 'Issue keys separated by `␣`');

program.parse();

const options = program.opts();

if (options.legend) {
console.log(getLegend());
process.exit(0);
}

const token = process.env.JIRA_API_TOKEN ?? tokenUnavailable();
const jira = new Jira('https://issues.redhat.com', token);

const version = await jira.getVersion();
console.debug(`JIRA Version: ${version}`);

const options = program.opts();

const argsParsed = z.array(issueIdSchema).safeParse(program.args);
const args = argsParsed.success
? argsParsed.data
Expand Down

0 comments on commit 811d990

Please sign in to comment.