Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Implemented pagination support #453

Merged
merged 8 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions apps/cli/src/commands/environment/list.environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type CommandArgument
} from 'src/types/command/command.types'
import { Logger } from '@/util/logger'
import { getPaginationOptions } from '@/util/pagination-options'
import { PAGINATION_OPTION } from '@/util/pagination-options'

export class ListEnvironment extends BaseCommand {
getName(): string {
Expand All @@ -27,7 +27,7 @@ export class ListEnvironment extends BaseCommand {
}

getOptions(): CommandOption[] {
return getPaginationOptions()
return PAGINATION_OPTION
}

async action({ args, options }: CommandActionData): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions apps/cli/src/commands/workspace/list.workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseCommand from '@/commands/base.command'
import { Logger } from '@/util/logger'
import ControllerInstance from '@/util/controller-instance'
import { CommandActionData, CommandOption } from '@/types/command/command.types'
import { getPaginationOptions } from '@/util/pagination-options'
import { PAGINATION_OPTION } from '@/util/pagination-options'

export default class ListWorkspace extends BaseCommand {
getName(): string {
Expand All @@ -14,7 +14,7 @@ export default class ListWorkspace extends BaseCommand {
}

getOptions(): CommandOption[] {
return getPaginationOptions()
return PAGINATION_OPTION
}

async action({ options }: CommandActionData): Promise<void> {
Expand Down
60 changes: 28 additions & 32 deletions apps/cli/src/util/pagination-options.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
import { CommandOption } from '@/types/command/command.types'

export const getPaginationOptions = (): CommandOption[] => {
return [
{
short: '-p',
long: '--page <int>',
description: 'Index of the page.'
},
{
short: '-l',
long: '--limit <int>',
description: 'Total number of items per page.'
},
{
short: '-o',
long: '--order <string>',
description:
'Order to sort by - either ascending (ASC) or descending (DESC).'
},
{
short: '--sort',
long: '--sort <string>',
description: 'Field to sort by.'
},
{
short: '-s',
long: '--search <string>',
description: 'Search term.'
}
]
}
export const PAGINATION_OPTION = [
Nil2000 marked this conversation as resolved.
Show resolved Hide resolved
{
short: '-p',
long: '--page <int>',
description: 'Index of the page.'
},
{
short: '-l',
long: '--limit <int>',
description: 'Total number of items per page.'
},
{
short: '-o',
long: '--order <string>',
description:
'Order to sort by - either ascending (ASC) or descending (DESC).'
},
{
short: '--sort',
long: '--sort <string>',
description: 'Field to sort by.'
},
{
short: '-s',
long: '--search <string>',
description: 'Search term.'
}
]