@@ -9,28 +9,28 @@ edition = "2024"
99[ dependencies]
1010automation = { path = "../crates/automation" }
1111anyhow = "1.0"
12+ argh = "0.1"
1213---
1314
14- use std:: env;
1515use std:: path:: Path ;
1616
17- use anyhow:: { Context , Result } ;
17+ use anyhow:: Result ;
18+ use argh:: FromArgs ;
1819
1920/// Check external types in all workspace library crates.
2021///
21- /// Usage: check-external-types.rs <TOOLCHAIN>
22- ///
23- /// Arguments:
24- /// <TOOLCHAIN> The Rust toolchain to use (e.g., 'nightly-2025-08-06')
25- ///
2622/// This script iterates through all workspace packages and runs
2723/// `cargo check-external-types` on library crates to verify that
2824/// public APIs don't expose types from private dependencies.
25+ #[ derive( FromArgs ) ]
26+ struct Args {
27+ /// the Rust toolchain to use (e.g., 'nightly-2025-08-06')
28+ #[ argh( positional) ]
29+ toolchain : String ,
30+ }
31+
2932fn main ( ) -> Result < ( ) > {
30- let args: Vec < String > = env:: args ( ) . collect ( ) ;
31- let toolchain = args
32- . get ( 1 )
33- . context ( "Missing required toolchain argument (e.g., 'nightly-2025-08-06')" ) ?;
33+ let args: Args = argh:: from_env ( ) ;
3434
3535 let workspace_root = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) . parent ( ) . unwrap ( ) ;
3636 let all_packages = automation:: list_packages ( workspace_root) ?;
@@ -43,7 +43,7 @@ fn main() -> Result<()> {
4343 println ! ( ) ;
4444 println ! ( "=== External Type Exposure Check ===" ) ;
4545 println ! ( ) ;
46- println ! ( "Toolchain: {}" , toolchain) ;
46+ println ! ( "Toolchain: {}" , args . toolchain) ;
4747 println ! ( "Checking {} crate(s)" , filtered_packages. len( ) ) ;
4848 println ! ( "Skipped internal crates: {}" , automation:: INTERNAL_CRATES . join( ", " ) ) ;
4949 println ! ( ) ;
@@ -57,7 +57,7 @@ fn main() -> Result<()> {
5757
5858 if has_lib {
5959 println ! ( "Checking external types in {}" , pkg. name) ;
60- check_external_types ( & pkg. manifest_path , toolchain) ?;
60+ check_external_types ( & pkg. manifest_path , & args . toolchain ) ?;
6161 println ! ( "✓ Passed: {}" , pkg. name) ;
6262 checked += 1 ;
6363 } else {
0 commit comments