( self: Instruction, prefix: ReadonlyArray<string>, config: CliConfig.CliConfig )
| 869 | const optionsWizardHeader = InternalSpan.code("Options Wizard - ") |
| 870 | |
| 871 | const wizardInternal = ( |
| 872 | self: Instruction, |
| 873 | prefix: ReadonlyArray<string>, |
| 874 | config: CliConfig.CliConfig |
| 875 | ): Effect.Effect< |
| 876 | Array<string>, |
| 877 | Terminal.QuitException | ValidationError.ValidationError, |
| 878 | FileSystem.FileSystem | Path.Path | Terminal.Terminal |
| 879 | > => { |
| 880 | const loop = ( |
| 881 | self: Instruction, |
| 882 | commandLineRef: Ref.Ref<ReadonlyArray<string>> |
| 883 | ): Effect.Effect< |
| 884 | ReadonlyArray<string>, |
| 885 | Terminal.QuitException | ValidationError.ValidationError, |
| 886 | FileSystem.FileSystem | Path.Path | Terminal.Terminal |
| 887 | > => { |
| 888 | switch (self._tag) { |
| 889 | case "GetUserInput": |
| 890 | case "Standard": { |
| 891 | return Effect.gen(function*() { |
| 892 | const logCurrentCommand = Ref.get(commandLineRef).pipe(Effect.flatMap((commandLine) => { |
| 893 | const currentCommand = InternalHelpDoc.p(pipe( |
| 894 | InternalSpan.strong(InternalSpan.highlight("COMMAND:", Color.cyan)), |
| 895 | InternalSpan.concat(InternalSpan.space), |
| 896 | InternalSpan.concat(InternalSpan.highlight( |
| 897 | Arr.join(commandLine, " "), |
| 898 | Color.magenta |
| 899 | )) |
| 900 | )) |
| 901 | return Console.log(InternalHelpDoc.toAnsiText(currentCommand)) |
| 902 | })) |
| 903 | if (isStandard(self)) { |
| 904 | // Log the current command line arguments |
| 905 | yield* logCurrentCommand |
| 906 | const commandName = InternalSpan.highlight(self.name, Color.magenta) |
| 907 | // If the command has options, run the wizard for them |
| 908 | if (!InternalOptions.isEmpty(self.options as InternalOptions.Instruction)) { |
| 909 | const message = InternalHelpDoc.p( |
| 910 | InternalSpan.concat(optionsWizardHeader, commandName) |
| 911 | ) |
| 912 | yield* Console.log(InternalHelpDoc.toAnsiText(message)) |
| 913 | const options = yield* InternalOptions.wizard(self.options, config) |
| 914 | yield* Ref.updateAndGet(commandLineRef, Arr.appendAll(options)) |
| 915 | yield* logCurrentCommand |
| 916 | } |
| 917 | // If the command has args, run the wizard for them |
| 918 | if (!InternalArgs.isEmpty(self.args as InternalArgs.Instruction)) { |
| 919 | const message = InternalHelpDoc.p( |
| 920 | InternalSpan.concat(argsWizardHeader, commandName) |
| 921 | ) |
| 922 | yield* Console.log(InternalHelpDoc.toAnsiText(message)) |
| 923 | const options = yield* InternalArgs.wizard(self.args, config) |
| 924 | yield* Ref.updateAndGet(commandLineRef, Arr.appendAll(options)) |
| 925 | yield* logCurrentCommand |
| 926 | } |
| 927 | } |
| 928 | return yield* Ref.get(commandLineRef) |
no test coverage detected