Skip to content

Add optional .ftpsync.json config file#4

Merged
OzzyCzech merged 1 commit into
mainfrom
config-file
Jun 17, 2026
Merged

Add optional .ftpsync.json config file#4
OzzyCzech merged 1 commit into
mainfrom
config-file

Conversation

@OzzyCzech

Copy link
Copy Markdown
Owner

Resolves #1.

Pre-fill non-secret deploy options from an optional .ftpsync.json so repeated deploys don't retype --server, --exclude, --file-perms, etc. Lean, 1:1 mapping to the existing flags — no new configuration magic.

Behavior

  • Optional & auto-discovered: default .ftpsync.json in CWD; missing default file is silently skipped. --config <PATH> overrides (a missing explicit path errors). No upward tree search.
  • Precedence: default → file → CLI. A CLI flag always overrides the file (via clap's ValueSource); the file overrides the built-in default.
  • List flags merge: include / exclude / purge from file + CLI are combined, CLI appended last.
  • No password in the file: there's no password key — it stays in -p / FTPSYNC_PASSWORD. Per-run toggles (--dry-run/-v/-q) are also file-excluded.
  • Unknown keys are errors (deny_unknown_fields) — a typo fails loudly and the error lists every valid key.
  • The config file is never uploaded (excluded like the state file).

Changes

  • src/cli.rsserver/username/passwordOption<String>; new --config <PATH>; SecureMode gets Deserialize.
  • src/config_file.rs (new) — FileConfig (serde, kebab-case, deny_unknown_fields) + load(path, explicit).
  • src/config.rsfrom_argsbuild(args, file, &matches) with merge/precedence + post-merge required-field validation.
  • src/main.rs — parse via ArgMatches so build can read ValueSource.
  • src/walker.rs — skip the config file on upload.
  • README "Configuration file" section + Quick start mention; CLAUDE.md module map + precedence note.

Tests

32 pass (8 new): scalar precedence (CLI overrides / file fills default), Vec merge with CLI last, missing-required error, deny_unknown_fields / no-password-key, and the config file never being uploaded. cargo build / clippy -D warnings / fmt --check / test all green.

Pre-fill non-secret deploy options from an optional .ftpsync.json so
repeated deploys don't retype --server, --exclude, --file-perms, etc.

- cli.rs: server/username/password become Option (file may supply them);
  new --config <PATH> flag.
- config_file.rs (new): serde FileConfig, kebab-case, deny_unknown_fields,
  load(path, explicit) — missing default file is silently skipped.
- config.rs: from_args -> build(args, file, &matches). Precedence is
  default -> file -> CLI via clap ValueSource; list flags (include/
  exclude/purge) merge with CLI appended last; required fields validated
  after the merge with a clear hint.
- main.rs: parse via ArgMatches so build() can read ValueSource.
- walker.rs: exclude the config file from upload like the state file.

Hard rules: no password key in the file (stays in -p / FTPSYNC_PASSWORD);
CLI always overrides the file. Docs updated (README section + CLAUDE.md).

Closes #1
@OzzyCzech OzzyCzech merged commit a562b97 into main Jun 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional .ftpsync.json config file

1 participant