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

[NayNay] Help text for command options #261

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const program = new Command()
program
.name('entropy')
.description('CLI interface for interacting with entropy.xyz. Running this binary without any commands or arguments starts a text-based interface.')
.addOption(accountOption())
.addOption(accountOption(program))
.addOption(endpointOption())
.addOption(
new Option(
Expand Down
7 changes: 5 additions & 2 deletions src/common/utils-cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Entropy from '@entropyxyz/sdk'
import { Option } from 'commander'
import { Command, Option } from 'commander'
import { findAccountByAddressOrName, stringify } from './utils'
import * as config from '../config'
import { initializeEntropy } from './initializeEntropy'
Expand Down Expand Up @@ -42,7 +42,7 @@ export function endpointOption () {
// NOTE: argParser is only run IF an option is provided, so this cannot be 'test-net'
}

export function accountOption () {
export function accountOption (program?: Command) {
const storedConfig = getConfigOrNull()

return new Option(
Expand All @@ -54,6 +54,9 @@ export function accountOption () {
)
.env('ENTROPY_ACCOUNT')
.argParser(async (account) => {
if (account === '-h' || account === '--help') {
program.help()
}
if (storedConfig && storedConfig.selectedAccount !== account) {
// Updated selected account in config with new address from this option
await config.set({
Expand Down
Loading