Skip to content

Commit 37284d2

Browse files
authored
Allow --json and --markdown in repos command (#500)
1 parent 7676b3e commit 37284d2

File tree

7 files changed

+15
-6
lines changed

7 files changed

+15
-6
lines changed

src/commands/repos/cmd-repos-create.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { logger } from '@socketsecurity/registry/lib/logger'
22

33
import { handleCreateRepo } from './handle-create-repo.mts'
44
import constants from '../../constants.mts'
5-
import { commonFlags } from '../../flags.mts'
5+
import { commonFlags, outputFlags } from '../../flags.mts'
66
import { checkCommandInput } from '../../utils/check-input.mts'
77
import { isTestingV1 } from '../../utils/config.mts'
88
import { determineOrgSlug } from '../../utils/determine-org-slug.mts'
@@ -21,6 +21,7 @@ const config: CliCommandConfig = {
2121
hidden: false,
2222
flags: {
2323
...commonFlags,
24+
...outputFlags,
2425
defaultBranch: {
2526
type: 'string',
2627
shortFlag: 'b',

src/commands/repos/cmd-repos-create.test.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ describe('socket repos create', async () => {
3232
--help Print this help
3333
--homepage Repository url
3434
--interactive Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.
35+
--json Output result as json
36+
--markdown Output result as markdown
3537
--org Force override the organization slug, overrides the default org from config
3638
--repoDescription Repository description
3739
--repoName Repository name

src/commands/repos/cmd-repos-del.mts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { logger } from '@socketsecurity/registry/lib/logger'
22

33
import { handleDeleteRepo } from './handle-delete-repo.mts'
44
import constants from '../../constants.mts'
5-
import { commonFlags } from '../../flags.mts'
5+
import { commonFlags, outputFlags } from '../../flags.mts'
66
import { checkCommandInput } from '../../utils/check-input.mts'
77
import { isTestingV1 } from '../../utils/config.mts'
88
import { determineOrgSlug } from '../../utils/determine-org-slug.mts'
@@ -21,6 +21,7 @@ const config: CliCommandConfig = {
2121
hidden: false,
2222
flags: {
2323
...commonFlags,
24+
...outputFlags,
2425
interactive: {
2526
type: 'boolean',
2627
default: true,
@@ -68,7 +69,7 @@ async function run(
6869
})
6970

7071
const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
71-
const outputKind = getOutputKind(json, markdown) // TODO: impl json/md further
72+
const outputKind = getOutputKind(json, markdown)
7273

7374
const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
7475
String(orgFlag || ''),

src/commands/repos/cmd-repos-del.test.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ describe('socket repos del', async () => {
3030
Options
3131
--help Print this help
3232
--interactive Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.
33+
--json Output result as json
34+
--markdown Output result as markdown
3335
--org Force override the organization slug, overrides the default org from config
3436
3537
Examples

src/commands/repos/cmd-repos-list.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const config: CliCommandConfig = {
2121
hidden: false,
2222
flags: {
2323
...commonFlags,
24+
...outputFlags,
2425
sort: {
2526
type: 'string',
2627
shortFlag: 's',
@@ -54,8 +55,7 @@ const config: CliCommandConfig = {
5455
shortFlag: 'p',
5556
default: 1,
5657
description: 'Page number'
57-
},
58-
...outputFlags
58+
}
5959
},
6060
help: (command, config) => `
6161
Usage

src/commands/repos/cmd-repos-update.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { logger } from '@socketsecurity/registry/lib/logger'
22

33
import { handleUpdateRepo } from './handle-update-repo.mts'
44
import constants from '../../constants.mts'
5-
import { commonFlags } from '../../flags.mts'
5+
import { commonFlags, outputFlags } from '../../flags.mts'
66
import { checkCommandInput } from '../../utils/check-input.mts'
77
import { isTestingV1 } from '../../utils/config.mts'
88
import { determineOrgSlug } from '../../utils/determine-org-slug.mts'
@@ -21,6 +21,7 @@ const config: CliCommandConfig = {
2121
hidden: false,
2222
flags: {
2323
...commonFlags,
24+
...outputFlags,
2425
defaultBranch: {
2526
type: 'string',
2627
shortFlag: 'b',

src/commands/repos/cmd-repos-update.test.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ describe('socket repos update', async () => {
3232
--help Print this help
3333
--homepage Repository url
3434
--interactive Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.
35+
--json Output result as json
36+
--markdown Output result as markdown
3537
--org Force override the organization slug, overrides the default org from config
3638
--repoDescription Repository description
3739
--repoName Repository name

0 commit comments

Comments
 (0)