Add optional .ftpsync.json config file#4
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1.
Pre-fill non-secret deploy options from an optional
.ftpsync.jsonso repeated deploys don't retype--server,--exclude,--file-perms, etc. Lean, 1:1 mapping to the existing flags — no new configuration magic.Behavior
.ftpsync.jsonin CWD; missing default file is silently skipped.--config <PATH>overrides (a missing explicit path errors). No upward tree search.ValueSource); the file overrides the built-in default.include/exclude/purgefrom file + CLI are combined, CLI appended last.passwordkey — it stays in-p/FTPSYNC_PASSWORD. Per-run toggles (--dry-run/-v/-q) are also file-excluded.deny_unknown_fields) — a typo fails loudly and the error lists every valid key.Changes
src/cli.rs—server/username/password→Option<String>; new--config <PATH>;SecureModegetsDeserialize.src/config_file.rs(new) —FileConfig(serde, kebab-case,deny_unknown_fields) +load(path, explicit).src/config.rs—from_args→build(args, file, &matches)with merge/precedence + post-merge required-field validation.src/main.rs— parse viaArgMatchessobuildcan readValueSource.src/walker.rs— skip the config file on upload.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/testall green.