Refactor CLI args and add input validation with shift range support#9
Merged
Merged
Conversation
- CLIヘルプテキストのシフト範囲記述を実態に合わせて修正 - prompt_for_shiftに範囲外警告付きバリデーション追加(validate_shift_input関数抽出) - encrypt_safe/decrypt_safeで空白文字のみのテキストを拒否するよう修正 - get_input_textに入力サイズ制限(10MB)を追加 - ブルートフォースでshift=0(元テキスト)も表示するよう変更 - main.rsのVec<String>収集をenv::args().count()に簡略化 - Encrypt/DecryptのenumフィールドをCipherArgs構造体に共通化 - バージョンを1.0.3→1.0.4にバンプ https://claude.ai/code/session_01UwAwi9MgGMEYuzf5NqHPuF
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.
Summary
This PR refactors the CLI argument handling to reduce code duplication, adds comprehensive input size validation, expands shift value range support, and improves error messages for better user experience.
Key Changes
CLI Refactoring
CipherArgsstruct to consolidate common arguments betweenEncryptandDecryptcommands, eliminating ~40 lines of duplicated field definitionsEncrypt(CipherArgs)andDecrypt(CipherArgs)tuple struct syntaxrun_cli()Input Validation
MAX_INPUT_SIZEconstant (1MB) to prevent processing excessively large inputsShift Value Handling
MIN_SHIFTconstant (-25) to support negative shift valuesvalidate_shift_input()function with comprehensive validation:prompt_for_shift()to use new validation function and display more helpful promptsWhitespace Handling
Documentation & Tests
Minor Improvements
main()to useenv::args().count()instead of collecting into vectorhttps://claude.ai/code/session_01UwAwi9MgGMEYuzf5NqHPuF