@@ -667,88 +667,34 @@ fn parse(argv: &[String]) -> Result<Command, String> {
667667 action : None ,
668668 } )
669669 }
670- "skills" => {
670+ "skills" | "agents" | "hooks" | "plugin" => {
671+ let expected_action = match sub {
672+ "skills" => "validate" ,
673+ "agents" => "export" ,
674+ "hooks" => "audit" ,
675+ "plugin" => "package" ,
676+ _ => unreachable ! ( ) ,
677+ } ;
671678 if argv. len ( ) < 3 {
672- return Err ( "missing action for 'antigravity skills'. Usage: ctxt antigravity skills validate" . to_string ( ) ) ;
673- }
674- if argv[ 2 ] != "validate" {
675- return Err ( format ! (
676- "unsupported action '{}' for 'antigravity skills'" ,
677- argv[ 2 ]
678- ) ) ;
679- }
680- if argv. len ( ) > 3 {
681- return Err ( format ! (
682- "unexpected argument '{}' for 'antigravity skills validate'" ,
683- argv[ 3 ]
684- ) ) ;
685- }
686- Ok ( Command :: Antigravity {
687- subcommand : "skills" . to_string ( ) ,
688- action : Some ( "validate" . to_string ( ) ) ,
689- } )
690- }
691- "agents" => {
692- if argv. len ( ) < 3 {
693- return Err ( "missing action for 'antigravity agents'. Usage: ctxt antigravity agents export" . to_string ( ) ) ;
694- }
695- if argv[ 2 ] != "export" {
696- return Err ( format ! (
697- "unsupported action '{}' for 'antigravity agents'" ,
698- argv[ 2 ]
699- ) ) ;
700- }
701- if argv. len ( ) > 3 {
702679 return Err ( format ! (
703- "unexpected argument '{}' for 'antigravity agents export'" ,
704- argv[ 3 ]
705- ) ) ;
706- }
707- Ok ( Command :: Antigravity {
708- subcommand : "agents" . to_string ( ) ,
709- action : Some ( "export" . to_string ( ) ) ,
710- } )
711- }
712- "hooks" => {
713- if argv. len ( ) < 3 {
714- return Err ( "missing action for 'antigravity hooks'. Usage: ctxt antigravity hooks audit" . to_string ( ) ) ;
715- }
716- if argv[ 2 ] != "audit" {
717- return Err ( format ! (
718- "unsupported action '{}' for 'antigravity hooks'" ,
719- argv[ 2 ]
680+ "missing action for 'antigravity {sub}'. Usage: ctxt antigravity {sub} {expected_action}"
720681 ) ) ;
721682 }
722- if argv. len ( ) > 3 {
723- return Err ( format ! (
724- "unexpected argument '{}' for 'antigravity hooks audit'" ,
725- argv[ 3 ]
726- ) ) ;
727- }
728- Ok ( Command :: Antigravity {
729- subcommand : "hooks" . to_string ( ) ,
730- action : Some ( "audit" . to_string ( ) ) ,
731- } )
732- }
733- "plugin" => {
734- if argv. len ( ) < 3 {
735- return Err ( "missing action for 'antigravity plugin'. Usage: ctxt antigravity plugin package" . to_string ( ) ) ;
736- }
737- if argv[ 2 ] != "package" {
683+ if argv[ 2 ] != expected_action {
738684 return Err ( format ! (
739- "unsupported action '{}' for 'antigravity plugin '" ,
685+ "unsupported action '{}' for 'antigravity {sub} '" ,
740686 argv[ 2 ]
741687 ) ) ;
742688 }
743689 if argv. len ( ) > 3 {
744690 return Err ( format ! (
745- "unexpected argument '{}' for 'antigravity plugin package '" ,
691+ "unexpected argument '{}' for 'antigravity {sub} {expected_action} '" ,
746692 argv[ 3 ]
747693 ) ) ;
748694 }
749695 Ok ( Command :: Antigravity {
750- subcommand : "plugin" . to_string ( ) ,
751- action : Some ( "package" . to_string ( ) ) ,
696+ subcommand : sub . to_string ( ) ,
697+ action : Some ( expected_action . to_string ( ) ) ,
752698 } )
753699 }
754700 other => Err ( format ! ( "unsupported antigravity subcommand '{}'" , other) ) ,
0 commit comments