@@ -23,6 +23,20 @@ const menuCommand: Command = { _tag: "Menu" }
2323const statusCommand : Command = { _tag : "Status" }
2424const downAllCommand : Command = { _tag : "DownAll" }
2525
26+ // CHANGE: parse --active flag for apply-all command to restrict to running containers
27+ // WHY: allow users to apply config only to currently active containers via --active flag
28+ // QUOTE(ТЗ): "сделать это возможным через атрибут --active применять только к активным контейнерам, а не ко всем"
29+ // REF: issue-185
30+ // PURITY: CORE
31+ // EFFECT: n/a
32+ // INVARIANT: activeOnly is true only when --active flag is present
33+ // COMPLEXITY: O(n) where n = |args|
34+ const parseApplyAll = ( args : ReadonlyArray < string > ) : Either . Either < Command , ParseError > => {
35+ const activeOnly = args . includes ( "--active" )
36+ const command : Command = { _tag : "ApplyAll" , activeOnly }
37+ return Either . right ( command )
38+ }
39+
2640const parseCreate = ( args : ReadonlyArray < string > ) : Either . Either < Command , ParseError > =>
2741 Either . flatMap ( parseRawOptions ( args ) , ( raw ) => buildCreateCommand ( raw ) )
2842
@@ -75,6 +89,8 @@ export const parseArgs = (args: ReadonlyArray<string>): Either.Either<Command, P
7589 Match . when ( "ui" , ( ) => Either . right ( menuCommand ) )
7690 )
7791 . pipe (
92+ Match . when ( "apply-all" , ( ) => parseApplyAll ( rest ) ) ,
93+ Match . when ( "update-all" , ( ) => parseApplyAll ( rest ) ) ,
7894 Match . when ( "auth" , ( ) => parseAuth ( rest ) ) ,
7995 Match . when ( "open" , ( ) => parseAttach ( rest ) ) ,
8096 Match . when ( "apply" , ( ) => parseApply ( rest ) ) ,
0 commit comments