modifs.mineures sans commentaires
This commit is contained in:
		
							parent
							
								
									e24c298cd8
								
							
						
					
					
						commit
						7979dc5e69
					
				| @ -65,14 +65,14 @@ abstract class AbstractArgsParser { | ||||
|       if ($opt === "--") { | ||||
|         # fin des arguments facultatifs en entrée
 | ||||
|         $eoo = true; | ||||
|         if ($keepsep) $dest[] = $opt; | ||||
|         if ($keepsep) $dest[] = "--"; | ||||
|         break; | ||||
|       } | ||||
|       $dest[] = $opt; | ||||
|     } | ||||
|     if (!$eoo && $desti < $destmax) { | ||||
|       # pas assez d'arguments en entrée, terminer avec "--"
 | ||||
|       $dest[] = "--"; | ||||
|       if ($keepsep) $dest[] = "--"; | ||||
|     } | ||||
|     return 0; | ||||
|   } | ||||
|  | ||||
| @ -239,7 +239,8 @@ class Aodef { | ||||
|   } | ||||
| 
 | ||||
|   function addOptions(?array $options): void { | ||||
|     A::merge($this->_options, $this->buildOptions($options)); | ||||
|     // les options pouvant être numériques (e.g "-1"), utiliser A::merge2
 | ||||
|     A::merge2($this->_options, $this->buildOptions($options)); | ||||
|     $this->updateType(); | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -12,6 +12,21 @@ Application::run(new class extends Application { | ||||
|     "usage" => "-A|-a|-b", | ||||
| 
 | ||||
|     "merge" => parent::ARGS, | ||||
|     "sections" => [ | ||||
|       [ | ||||
|         "title" => "Section X", | ||||
|         "show" => false, | ||||
|         ["group", | ||||
|          ["-X:", "--setx", "args" => "int", "name" => "x", | ||||
|           "help" => "spécifier x", | ||||
|          ], | ||||
|          ["--setx10", "name" => "x", "value" => 10], | ||||
|          ["--setx20", "name" => "x", "value" => 20], | ||||
|         ], | ||||
|         ["-x", "--incx", "name" => "x"], | ||||
|         ["-y", "--decx", "name" => "x", "inverse" => true], | ||||
|       ], | ||||
|     ], | ||||
|     ["group", | ||||
|       ["-A:", "--seta", "args" => "int", "name" => "a", | ||||
|         "help" => "spécifier a", | ||||
| @ -28,27 +43,19 @@ Application::run(new class extends Application { | ||||
|     ["-D::", "--override", | ||||
|       "help" => "++remplace celui de la section principale", | ||||
|     ], | ||||
|     "sections" => [ | ||||
|       [ | ||||
|         "title" => "Section X", | ||||
|         "show" => false, | ||||
|         ["group", | ||||
|           ["-X:", "--setx", "args" => "int", "name" => "x", | ||||
|             "help" => "spécifier x", | ||||
|           ], | ||||
|           ["--setx10", "name" => "x", "value" => 10], | ||||
|           ["--setx20", "name" => "x", "value" => 20], | ||||
|         ], | ||||
|         ["-x", "--incx", "name" => "x"], | ||||
|         ["-y", "--decx", "name" => "x", "inverse" => true], | ||||
|       ], | ||||
|     ], | ||||
|     ["args" => [["value", "value"]], "name" => "args"], | ||||
|     ["-1:first", "--one", "help" => "un argument"], | ||||
|     ["-2:first,second", "--two", "help" => "deux arguments"], | ||||
|     ["-3", "args" => ""], | ||||
|     //["args" => [["value", "value"]], "name" => "args"],
 | ||||
|     //["args" => ["value", ["value"]], "name" => "args"],
 | ||||
|     //["args" => ["value", "value"], "name" => "args"],
 | ||||
|   ]; | ||||
| 
 | ||||
|   private ?int $a = null; | ||||
|   private ?int $x = null; | ||||
|   private ?string $override = null; | ||||
|   private ?string $one = null; | ||||
|   private ?array $two = null; | ||||
| 
 | ||||
|   function main() { | ||||
|     $profile = app::get_profile($productionMode); | ||||
| @ -63,6 +70,8 @@ Application::run(new class extends Application { | ||||
|       "\na=", var_export($this->a, true), | ||||
|       "\nx=", var_export($this->x, true), | ||||
|       "\noverride=", var_export($this->override, true), | ||||
|       "\none=", var_export($this->one, true), | ||||
|       "\ntwo=", var_export($this->two, true), | ||||
|       "\nargs=", var_export($this->args, true), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user