@@ -11,6 +11,7 @@ import {
1111import type { AppError } from "@effect-template/lib/usecases/errors"
1212import { renderError } from "@effect-template/lib/usecases/errors"
1313import { downAllDockerGitProjects , listProjectStatus } from "@effect-template/lib/usecases/projects"
14+ import { exportScrap , importScrap } from "@effect-template/lib/usecases/scrap"
1415import {
1516 stateCommit ,
1617 stateInit ,
@@ -68,27 +69,30 @@ type NonBaseCommand = Exclude<
6869>
6970
7071const handleNonBaseCommand = ( command : NonBaseCommand ) =>
71- Match . value ( command ) . pipe (
72- Match . when ( { _tag : "StatePath" } , ( ) => statePath ) ,
73- Match . when ( { _tag : "StateInit" } , ( cmd ) => stateInit ( cmd ) ) ,
74- Match . when ( { _tag : "StateStatus" } , ( ) => stateStatus ) ,
75- Match . when ( { _tag : "StatePull" } , ( ) => statePull ) ,
76- Match . when ( { _tag : "StateCommit" } , ( cmd ) => stateCommit ( cmd . message ) ) ,
77- Match . when ( { _tag : "StatePush" } , ( ) => statePush ) ,
78- Match . when ( { _tag : "StateSync" } , ( cmd ) => stateSync ( cmd . message ) ) ,
79- Match . when ( { _tag : "AuthGithubLogin" } , ( cmd ) => authGithubLogin ( cmd ) ) ,
80- Match . when ( { _tag : "AuthGithubStatus" } , ( cmd ) => authGithubStatus ( cmd ) ) ,
81- Match . when ( { _tag : "AuthGithubLogout" } , ( cmd ) => authGithubLogout ( cmd ) ) ,
82- Match . when ( { _tag : "AuthCodexLogin" } , ( cmd ) => authCodexLogin ( cmd ) ) ,
83- Match . when ( { _tag : "AuthCodexStatus" } , ( cmd ) => authCodexStatus ( cmd ) ) ,
84- Match . when ( { _tag : "AuthCodexLogout" } , ( cmd ) => authCodexLogout ( cmd ) ) ,
85- Match . when ( { _tag : "Attach" } , ( cmd ) => attachTmux ( cmd ) ) ,
86- Match . when ( { _tag : "Panes" } , ( cmd ) => listTmuxPanes ( cmd ) ) ,
87- Match . when ( { _tag : "SessionsList" } , ( cmd ) => listTerminalSessions ( cmd ) ) ,
88- Match . when ( { _tag : "SessionsKill" } , ( cmd ) => killTerminalProcess ( cmd ) ) ,
89- Match . when ( { _tag : "SessionsLogs" } , ( cmd ) => tailTerminalLogs ( cmd ) ) ,
90- Match . exhaustive
91- )
72+ Match . value ( command )
73+ . pipe (
74+ Match . when ( { _tag : "StatePath" } , ( ) => statePath ) ,
75+ Match . when ( { _tag : "StateInit" } , ( cmd ) => stateInit ( cmd ) ) ,
76+ Match . when ( { _tag : "StateStatus" } , ( ) => stateStatus ) ,
77+ Match . when ( { _tag : "StatePull" } , ( ) => statePull ) ,
78+ Match . when ( { _tag : "StateCommit" } , ( cmd ) => stateCommit ( cmd . message ) ) ,
79+ Match . when ( { _tag : "StatePush" } , ( ) => statePush ) ,
80+ Match . when ( { _tag : "StateSync" } , ( cmd ) => stateSync ( cmd . message ) ) ,
81+ Match . when ( { _tag : "AuthGithubLogin" } , ( cmd ) => authGithubLogin ( cmd ) ) ,
82+ Match . when ( { _tag : "AuthGithubStatus" } , ( cmd ) => authGithubStatus ( cmd ) ) ,
83+ Match . when ( { _tag : "AuthGithubLogout" } , ( cmd ) => authGithubLogout ( cmd ) ) ,
84+ Match . when ( { _tag : "AuthCodexLogin" } , ( cmd ) => authCodexLogin ( cmd ) ) ,
85+ Match . when ( { _tag : "AuthCodexStatus" } , ( cmd ) => authCodexStatus ( cmd ) ) ,
86+ Match . when ( { _tag : "AuthCodexLogout" } , ( cmd ) => authCodexLogout ( cmd ) ) ,
87+ Match . when ( { _tag : "Attach" } , ( cmd ) => attachTmux ( cmd ) ) ,
88+ Match . when ( { _tag : "Panes" } , ( cmd ) => listTmuxPanes ( cmd ) ) ,
89+ Match . when ( { _tag : "SessionsList" } , ( cmd ) => listTerminalSessions ( cmd ) ) ,
90+ Match . when ( { _tag : "SessionsKill" } , ( cmd ) => killTerminalProcess ( cmd ) ) ,
91+ Match . when ( { _tag : "SessionsLogs" } , ( cmd ) => tailTerminalLogs ( cmd ) ) ,
92+ Match . when ( { _tag : "ScrapExport" } , ( cmd ) => exportScrap ( cmd ) ) ,
93+ Match . when ( { _tag : "ScrapImport" } , ( cmd ) => importScrap ( cmd ) )
94+ )
95+ . pipe ( Match . exhaustive )
9296
9397// CHANGE: compose CLI program with typed errors and shell effects
9498// WHY: keep a thin entry layer over pure parsing and template generation
@@ -121,6 +125,9 @@ export const program = pipe(
121125 Effect . catchTag ( "DockerCommandError" , logWarningAndExit ) ,
122126 Effect . catchTag ( "AuthError" , logWarningAndExit ) ,
123127 Effect . catchTag ( "CommandFailedError" , logWarningAndExit ) ,
128+ Effect . catchTag ( "ScrapArchiveNotFoundError" , logErrorAndExit ) ,
129+ Effect . catchTag ( "ScrapTargetDirUnsupportedError" , logErrorAndExit ) ,
130+ Effect . catchTag ( "ScrapWipeRefusedError" , logErrorAndExit ) ,
124131 Effect . matchEffect ( {
125132 onFailure : ( error ) =>
126133 isParseError ( error )
0 commit comments