Skip to content

Commit

Permalink
show all settings when a name isn't specified
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed Nov 24, 2024
1 parent 956ac29 commit 79320fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/commands/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import settings from '~/settings'

export default function registerSettingsCommand(program: Command) {
program.command('settings')
.argument('<name>', 'Name of setting')
.argument('[value]', 'Value of setting')
.option('-s, --set', 'Set the value of the setting')
.description('Get or set stax settings')
.action((name, value, options) => {
if (options.set) {
value = settings.write(name, value)
console.log(`${icons.saved} Setting for '${name}' set to '${value}'`)
} else
console.log(settings.read(name))
.argument('[name]', 'Name of setting')
.argument('[value]', 'Value of setting')
.option('-s, --set', 'Set the value of the setting')
.description('Get or set stax settings')
.action((name, value, options) => {
if (options.set) {
value = settings.write(name, value)
console.log(`${icons.saved} Setting for '${name}' set to '${value}'`)
} else if (name) {
console.log(settings.read(name))
} else {
console.log(settings.all())
}
})
}
2 changes: 2 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function load() {
}

const settings = {
all: function() { return load() },

read: function(name: string, defaultValue: any | undefined = undefined) {
const settings = load()
return settings[name] || defaultValue
Expand Down

0 comments on commit 79320fd

Please sign in to comment.