mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-28 18:40:34 -05:00
Refactor CLI options: replace --quiet with --verbose for improved message control. Update related configurations and tests to reflect this change. Adjust build command in workflow for consistency.
This commit is contained in:
3
.github/actions/docs-spelling/expect.txt
vendored
3
.github/actions/docs-spelling/expect.txt
vendored
@@ -2,6 +2,7 @@ Abanca
|
||||
ABNAMRO
|
||||
ABNANL
|
||||
Activo
|
||||
actualrc
|
||||
AESUDEF
|
||||
ALZEY
|
||||
Anglais
|
||||
@@ -110,8 +111,8 @@ KBCBE
|
||||
Keycloak
|
||||
Khurozov
|
||||
KORT
|
||||
KRW
|
||||
Kreditbank
|
||||
KRW
|
||||
lage
|
||||
LHV
|
||||
LHVBEE
|
||||
|
||||
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -90,7 +90,7 @@ jobs:
|
||||
with:
|
||||
download-translations: 'false'
|
||||
- name: Build CLI
|
||||
run: cd packages/cli && yarn build
|
||||
run: yarn build:cli
|
||||
- name: Create package tgz
|
||||
run: cd packages/cli && yarn pack && mv package.tgz actual-cli.tgz
|
||||
- name: Upload Build
|
||||
|
||||
@@ -75,7 +75,7 @@ Create an `.actualrc.json` (or `.actualrc`, `.actualrc.yaml`, `actual.config.js`
|
||||
| `--budget-id <id>` | Budget Sync ID |
|
||||
| `--data-dir <path>` | Data directory |
|
||||
| `--format <format>` | Output format: `json` (default), `table`, `csv` |
|
||||
| `--quiet` | Suppress informational stderr messages |
|
||||
| `--verbose` | Show informational messages |
|
||||
|
||||
## Commands
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('accounts commands', () => {
|
||||
describe('list', () => {
|
||||
it('calls api.getAccounts and prints result', async () => {
|
||||
const accounts = [{ id: '1', name: 'Checking' }];
|
||||
vi.mocked(api.getAccounts).mockResolvedValue(accounts as never);
|
||||
vi.mocked(api.getAccounts).mockResolvedValue(accounts);
|
||||
|
||||
await run(['accounts', 'list']);
|
||||
|
||||
@@ -73,7 +73,7 @@ describe('accounts commands', () => {
|
||||
});
|
||||
|
||||
it('passes format option to printOutput', async () => {
|
||||
vi.mocked(api.getAccounts).mockResolvedValue([] as never);
|
||||
vi.mocked(api.getAccounts).mockResolvedValue([]);
|
||||
|
||||
await run(['--format', 'csv', 'accounts', 'list']);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export type CliGlobalOpts = {
|
||||
dataDir?: string;
|
||||
encryptionPassword?: string;
|
||||
format?: 'json' | 'table' | 'csv';
|
||||
quiet?: boolean;
|
||||
verbose?: boolean;
|
||||
};
|
||||
|
||||
type ConfigFileContent = {
|
||||
|
||||
@@ -45,9 +45,10 @@ describe('withConnection', () => {
|
||||
await withConnection({}, async () => 'ok');
|
||||
|
||||
expect(api.init).toHaveBeenCalledWith({
|
||||
serverUrl: 'http://test',
|
||||
serverURL: 'http://test',
|
||||
password: 'pw',
|
||||
dataDir: '/tmp/data',
|
||||
verbose: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,9 +58,10 @@ describe('withConnection', () => {
|
||||
await withConnection({}, async () => 'ok');
|
||||
|
||||
expect(api.init).toHaveBeenCalledWith({
|
||||
serverUrl: 'http://test',
|
||||
serverURL: 'http://test',
|
||||
sessionToken: 'tok',
|
||||
dataDir: '/tmp/data',
|
||||
verbose: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -117,17 +119,17 @@ describe('withConnection', () => {
|
||||
expect(api.shutdown).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('writes info to stderr when not quiet', async () => {
|
||||
it('does not write to stderr by default', async () => {
|
||||
await withConnection({}, async () => 'ok');
|
||||
|
||||
expect(stderrSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('writes info to stderr when verbose', async () => {
|
||||
await withConnection({ verbose: true }, async () => 'ok');
|
||||
|
||||
expect(stderrSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Connecting to'),
|
||||
);
|
||||
});
|
||||
|
||||
it('does not write to stderr when quiet', async () => {
|
||||
await withConnection({ quiet: true }, async () => 'ok');
|
||||
|
||||
expect(stderrSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,8 +5,8 @@ import * as api from '@actual-app/api';
|
||||
import { resolveConfig } from './config';
|
||||
import type { CliGlobalOpts } from './config';
|
||||
|
||||
function info(message: string, quiet?: boolean) {
|
||||
if (!quiet) {
|
||||
function info(message: string, verbose?: boolean) {
|
||||
if (verbose) {
|
||||
process.stderr.write(message + '\n');
|
||||
}
|
||||
}
|
||||
@@ -25,21 +25,21 @@ export async function withConnection<T>(
|
||||
|
||||
mkdirSync(config.dataDir, { recursive: true });
|
||||
|
||||
info(`Connecting to ${config.serverUrl}...`, globalOpts.quiet);
|
||||
info(`Connecting to ${config.serverUrl}...`, globalOpts.verbose);
|
||||
|
||||
if (config.sessionToken) {
|
||||
await api.init({
|
||||
serverURL: config.serverUrl,
|
||||
dataDir: config.dataDir,
|
||||
sessionToken: config.sessionToken,
|
||||
verbose: !globalOpts.quiet,
|
||||
verbose: globalOpts.verbose,
|
||||
});
|
||||
} else if (config.password) {
|
||||
await api.init({
|
||||
serverURL: config.serverUrl,
|
||||
dataDir: config.dataDir,
|
||||
password: config.password,
|
||||
verbose: !globalOpts.quiet,
|
||||
verbose: globalOpts.verbose,
|
||||
});
|
||||
} else {
|
||||
throw new Error(
|
||||
@@ -49,7 +49,7 @@ export async function withConnection<T>(
|
||||
|
||||
try {
|
||||
if (loadBudget && config.budgetId) {
|
||||
info(`Downloading budget ${config.budgetId}...`, globalOpts.quiet);
|
||||
info(`Downloading budget ${config.budgetId}...`, globalOpts.verbose);
|
||||
await api.downloadBudget(config.budgetId, {
|
||||
password: config.encryptionPassword,
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ program
|
||||
.choices(['json', 'table', 'csv'] as const)
|
||||
.default('json'),
|
||||
)
|
||||
.option('--quiet', 'Suppress informational messages', false);
|
||||
.option('--verbose', 'Show informational messages', false);
|
||||
|
||||
registerAccountsCommand(program);
|
||||
registerBudgetsCommand(program);
|
||||
|
||||
Reference in New Issue
Block a user