Skip to content

Commit

Permalink
Merge pull request #250 from vitalygashkov/next
Browse files Browse the repository at this point in the history
Improved settings formatting for `streamyx settings`, added command `set` to change settings property
  • Loading branch information
vitalygashkov authored Nov 19, 2024
2 parents 22794bb + 42d999d commit ab20e03
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/cli
Submodule cli updated from 12ad63 to 57e471
23 changes: 21 additions & 2 deletions packages/core/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,28 @@ export const saveSettings = async (settings: Partial<Settings>, customPath?: str
});
};

const printObject = (obj: any, depth = 0) => {
for (const [key, value] of Object.entries(obj)) {
const keyString = (' '.repeat(depth) + key).padEnd(30);
if (typeof value === 'object' && value !== null) {
console.log(keyString);
printObject(value, depth + 1);
} else {
const valueString = typeof value === 'string' ? `"${value}"` : JSON.stringify(value || '').replace('""', '');
console.log(`${keyString} ${valueString}`);
}
}
};

export const showSettings = async () => {
const settings = await loadSettings();
console.log(JSON.stringify(settings, null, 2));
console.log(`Edit settings.json here: ${BaseDirectory.AppData}`);
printObject(settings);
console.log(`\nEdit settings.json here: ${BaseDirectory.AppData}`);
return settings;
};

export const setParameter = async (parameter: string) => {
const [key, value] = parameter.split('=');
await saveSettings({ [key]: value });
console.log('Settings updated');
};

0 comments on commit ab20e03

Please sign in to comment.