packages feed

hstratus-0.1.2.0 / src / Hstratus / Cli.hs

{- |Module      : Hstratus.CliCopyright   : (c) 2026 Tim EmiolaMaintainer  : Tim Emiola <adetokunbo@emio.la>SPDX-License-Identifier: BSD-3-ClauseTop-level CLI parser and dispatch for the hstratus command-line tool.-}module Hstratus.Cli  ( TopCommand (..)  , cliParser  , run  )whereimport Hstratus.Cli.Auth (AuthCommand, authParser, runAuth)import Hstratus.Cli.Drive (DriveCommand, driveParser, runDrive)import Hstratus.Cli.Notes (NotesCommand, notesParser, runNotes)import Options.Applicativedata TopCommand  = AuthCmd !AuthCommand  | DriveCmd !DriveCommand  | NotesCmd !NotesCommand  deriving (Eq, Show)cliParser :: ParserInfo TopCommandcliParser =  info    (topParser <**> helper)    (fullDesc <> progDesc "hstratus: iCloud service tools")topParser :: Parser TopCommandtopParser =  subparser    ( command "auth" (info (AuthCmd <$> authParser <**> helper) (progDesc "iCloud authentication commands"))        <> command "drive" (info (DriveCmd <$> driveParser <**> helper) (progDesc "iCloud Drive commands"))        <> command "notes" (info (NotesCmd <$> notesParser <**> helper) (progDesc "iCloud Notes commands"))    )run :: IO ()run = execParser cliParser >>= dispatchdispatch :: TopCommand -> IO ()dispatch (AuthCmd cmd) = runAuth cmddispatch (DriveCmd cmd) = runDrive cmddispatch (NotesCmd cmd) = runNotes cmd