Skip to content

Commit

Permalink
prettify logo
Browse files Browse the repository at this point in the history
  • Loading branch information
jairad26 committed Oct 24, 2024
1 parent 543572d commit e6b68b9
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 1 deletion.
36 changes: 36 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"chalk": "^5.3.0",
"dotenv": "^16.4.5",
"fetch": "^1.1.0",
"gradient-string": "^3.0.0",
"node-fetch": "^3.3.2",
"node-persist": "^4.0.3",
"open": "^10.1.0",
Expand Down
19 changes: 19 additions & 0 deletions src/custom/header.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2024 Hypermode Inc.
* Licensed under the terms of the Apache License, Version 2.0
* See the LICENSE file that accompanied this code for further details.
*
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

import {getLogo} from './logo.js'

export function getHeader(cliVersion: string): string {
let out = ''
out += getLogo()
out += '\n'
out += `Modus CLI v${cliVersion}`
out += '\n'
return out
}
9 changes: 9 additions & 0 deletions src/custom/help.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {Command, Help, Interfaces} from '@oclif/core'
import chalk from 'chalk'

import {getHeader} from './header.js'

const CLI_VERSION = '0.0.0'

export default class CustomHelp extends Help {
Expand Down Expand Up @@ -45,6 +47,10 @@ export default class CustomHelp extends Help {
return out.trim()
}

formatHeader(): string {
return getHeader(this.config.version)
}

formatRoot(): string {
let out = ''
out
Expand Down Expand Up @@ -104,6 +110,7 @@ export default class CustomHelp extends Help {
}

async showCommandHelp(command: Command.Loadable): Promise<void> {
this.log(this.formatHeader())
const margin = 20
const name = command.id.replaceAll(':', ' ')
const args = Object.keys(command.args)
Expand Down Expand Up @@ -149,6 +156,7 @@ export default class CustomHelp extends Help {
}

async showRootHelp(): Promise<void> {
this.log(this.formatHeader())
let rootTopics = this.sortedTopics
let rootCommands = this.sortedCommands
const state = this.config.pjson?.oclif?.state
Expand Down Expand Up @@ -201,6 +209,7 @@ export default class CustomHelp extends Help {
}

async showTopicHelp(topic: Interfaces.Topic) {
this.log(this.formatHeader())
const {name} = topic
const commands = this.sortedCommands.filter(c => c.id.startsWith(name + ':'))
for (const command of commands) {
Expand Down
22 changes: 22 additions & 0 deletions src/custom/logo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2024 Hypermode Inc.
* Licensed under the terms of the Apache License, Version 2.0
* See the LICENSE file that accompanied this code for further details.
*
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

import gradient from 'gradient-string'

const logo = String.raw`
__ __ __
/ // /_ _____ ___ ______ _ ___ ___/ /__
/ _ / // / _ \/ -_) __/ ' \/ _ \/ _ / -_)
/_//_/\_, / .__/\__/_/ /_/_/_/\___/\_,_/\__/
/___/_/
`

export function getLogo(): string {
return gradient(['#E3BFFF', '#602AF8']).multiline(logo)
}
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./src/index.ts","./src/commands/login/index.ts","./src/commands/logout/index.ts","./src/commands/org/switch.ts","./src/custom/help.ts","./src/util/index.ts"],"version":"5.6.2"}
{"root":["./src/index.ts","./src/commands/login/index.ts","./src/commands/logout/index.ts","./src/commands/org/switch.ts","./src/custom/header.ts","./src/custom/help.ts","./src/custom/logo.ts","./src/util/index.ts"],"version":"5.6.2"}

0 comments on commit e6b68b9

Please sign in to comment.