@@ -33,6 +33,7 @@ fn main() -> anyhow::Result<()> {
3333 || path. starts_with ( "http://" )
3434 || path. starts_with ( "https://" )
3535 } )
36+ . take ( 1 )
3637 . collect ( ) ;
3738
3839 if url_paths. len ( ) > 1 {
@@ -45,8 +46,37 @@ fn main() -> anyhow::Result<()> {
4546 if GitProcessor :: is_git_url ( url_path) {
4647 let git_processor = GitProcessor :: new ( ) ?;
4748 let repo_path = git_processor. process_repo ( url_path) ?;
48- process_directory ( & args. with_path ( repo_path. to_str ( ) . unwrap ( ) ) ) ?;
49+ args. validate_args ( true ) ?;
50+
51+ let mut subpaths: Vec < String > = vec ! [ ] ;
52+ let mut found_url = false ;
53+ for p in & args. paths {
54+ if !found_url && p. as_str ( ) == url_path. as_str ( ) {
55+ found_url = true ;
56+ continue ;
57+ }
58+ if found_url {
59+ subpaths. push ( p. clone ( ) ) ;
60+ }
61+ }
62+
63+ let process_args = if subpaths. is_empty ( ) {
64+ // No subpaths specified, process the whole repo
65+ args. with_path ( repo_path. to_str ( ) . unwrap ( ) )
66+ } else {
67+ // Process only the specified subpaths inside the repo
68+ let mut new_args = args. clone ( ) ;
69+ new_args. paths = subpaths. iter ( ) . map ( |sub| {
70+ // Join with repo_path
71+ let mut joined = std:: path:: PathBuf :: from ( & repo_path) ;
72+ joined. push ( sub) ;
73+ joined. to_string_lossy ( ) . to_string ( )
74+ } ) . collect ( ) ;
75+ new_args
76+ } ;
77+ process_directory ( & process_args) ?;
4978 } else if url_path. starts_with ( "http://" ) || url_path. starts_with ( "https://" ) {
79+ args. validate_args ( true ) ?;
5080 let link_depth = args. link_depth . unwrap_or ( config. default_link_depth ) ;
5181 let traverse = args. traverse_links || config. traverse_links ;
5282
@@ -60,6 +90,7 @@ fn main() -> anyhow::Result<()> {
6090 }
6191 }
6292 } else {
93+ args. validate_args ( false ) ?;
6394 process_directory ( & args) ?;
6495 }
6596
0 commit comments