-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add remote repository command #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cc590f2
3082b48
331383a
35b1849
389a399
2b7d4b3
f630ac2
a98541b
301f2a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| ## 1.7.0 - 2026-02-09 | ||
|
|
||
| Added | ||
| - `--repo` to process a remote git repository in a temporary directory. | ||
| - `--repo-branch` to checkout a branch or tag when using `--repo`. | ||
| - `--repo-commit` to checkout a specific commit when using `--repo`. | ||
| - Repository integration tests covering clone, cleanup, and commit checkout. | ||
|
|
||
| Changed | ||
| - Error handling now uses typed `AppError` variants (via `thiserror`), removing string-based checks for clipboard and config errors. | ||
| - When `--repo-commit` is used, cloning no longer uses `--depth 1` to ensure the commit is available. | ||
| - Documentation updated with a remote-repo usage example. | ||
| - Applied a formatting pass to keep code style consistent. | ||
|
|
||
| Fixed | ||
| - CLI now prevents using `--repo` and `--dir` together. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,26 @@ pub fn create_commands() -> Command { | |||||
| .help("Sets the output file") | ||||||
| .default_value("fyai.txt"), | ||||||
| ) | ||||||
| .arg( | ||||||
| Arg::new("repo") | ||||||
| .long("repo") | ||||||
| .value_name("URL") | ||||||
| .help("Clone a git repository (GitHub/GitLab) into a temporary directory before processing").conflicts_with("directory"), | ||||||
|
||||||
| .help("Clone a git repository (GitHub/GitLab) into a temporary directory before processing").conflicts_with("directory"), | |
| .help("Clone a git repository (GitHub/GitLab) into a temporary directory before processing"), |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,21 @@ | ||
| use clipboard::{ClipboardContext, ClipboardProvider}; | ||
| use std::fs::File; | ||
| use std::io::{self, Error, Read}; | ||
| use std::io::Read; | ||
| use std::path::Path; | ||
|
|
||
| use crate::error::{AppError, AppResult}; | ||
|
|
||
| /// Copies the contents of the specified file to the system clipboard. | ||
| pub fn copy_to_clipboard(output_path: &Path) -> io::Result<()> { | ||
| pub fn copy_to_clipboard(output_path: &Path) -> AppResult<()> { | ||
| let mut output_contents = String::new(); | ||
| File::open(output_path)?.read_to_string(&mut output_contents)?; | ||
|
|
||
| let mut clipboard: ClipboardContext = | ||
| ClipboardProvider::new().map_err(|e| Error::other(format!("Clipboard error: {}", e)))?; | ||
| ClipboardProvider::new().map_err(|e| AppError::Clipboard(e.to_string()))?; | ||
|
|
||
| clipboard | ||
| .set_contents(output_contents) | ||
| .map_err(|e| Error::other(format!("Clipboard error: {}", e)))?; | ||
| .map_err(|e| AppError::Clipboard(e.to_string()))?; | ||
|
|
||
| Ok(()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| use std::io; | ||
| use std::path::PathBuf; | ||
|
|
||
| use thiserror::Error; | ||
|
|
||
| pub type AppResult<T> = Result<T, AppError>; | ||
|
|
||
| #[derive(Debug, Error)] | ||
| pub enum AppError { | ||
| #[error(transparent)] | ||
| Io(#[from] io::Error), | ||
|
|
||
| #[error("Clipboard error: {0}")] | ||
| Clipboard(String), | ||
|
|
||
| #[error("YAML parse error in {path}: {source}")] | ||
| YamlParse { | ||
| path: PathBuf, | ||
| #[source] | ||
| source: serde_yaml::Error, | ||
| }, | ||
|
|
||
| #[error("Missing directory")] | ||
| MissingDirectory, | ||
|
|
||
| #[error("Missing output")] | ||
| MissingOutput, | ||
|
|
||
| #[error("Invalid min-size")] | ||
| InvalidMinSize, | ||
|
|
||
| #[error("Invalid max-size")] | ||
| InvalidMaxSize, | ||
|
|
||
| #[error("Config file already exists at {path}. Use --force to overwrite.")] | ||
| ConfigAlreadyExists { path: String }, | ||
|
|
||
| #[error("Failed to run git clone: {0}")] | ||
| GitCloneExec(#[source] io::Error), | ||
|
|
||
| #[error("git clone failed: {0}")] | ||
| GitCloneFailed(String), | ||
|
|
||
| #[error("Failed to run git checkout: {0}")] | ||
| GitCheckoutExec(#[source] io::Error), | ||
|
|
||
| #[error("git checkout failed: {0}")] | ||
| GitCheckoutFailed(String), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a direct dependency on
thiserror = "1.0"introduces a secondthiserrormajor version alongside an existing transitivethiserror 2.x(see Cargo.lock), increasing compile time and binary size. Prefer aligning to the already-used major version (if MSRV allows) or otherwise pin/justify the dual-version situation.