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:
Matiss Janis Aboltins
2026-03-15 18:20:49 +00:00
parent b16e5d685c
commit 70b802da39
8 changed files with 25 additions and 22 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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']);

View File

@@ -20,7 +20,7 @@ export type CliGlobalOpts = {
dataDir?: string;
encryptionPassword?: string;
format?: 'json' | 'table' | 'csv';
quiet?: boolean;
verbose?: boolean;
};
type ConfigFileContent = {

View File

@@ -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();
});
});

View File

@@ -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,
});

View File

@@ -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);