Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running shell commands #28

Open
1 task
chshersh opened this issue Jun 13, 2022 · 0 comments
Open
1 task

Running shell commands #28

chshersh opened this issue Jun 13, 2022 · 0 comments
Labels
good first issue Good for newcomers

Comments

@chshersh
Copy link
Owner

chshersh commented Jun 13, 2022

Implement functions to run Shell commands easier in the Iris applications. A simple implementation would be something like this (inspired by shellmet):

-- | Run the command but don't print it
shellSilent
    :: FilePath  -- ^ Executable name
    -> [Text]    -- ^ Arguments
    -> IO ()

-- | Run the command and print the command itself to stderr
shell
    :: Text      -- ^ Prompt
    -> FilePath  -- ^ Executable name
    -> [Text]    -- ^ Arguments
    -> IO ()

-- | Run the command, don't print it and return its stdout
shellRetSilent
    :: FilePath  -- ^ Executable name
    -> [Text]    -- ^ Arguments
    -> IO Text

-- | Run the command, print it with prompt to stderr and return its stdout
shellRet
    :: Text      -- ^ Prompt
    -> FilePath  -- ^ Executable name
    -> [Text]    -- ^ Arguments
    -> IO Text

Alternatively, we can integrate with one of the existing and battle-tested libraries:

Possible usage inside Iris itself — Iris.Browse module:

iris/src/Iris/Browse.hs

Lines 69 to 74 in 7e69433

-- | Execute a command with arguments.
runCommand :: FilePath -> [String] -> IO ()
runCommand cmd args = do
let cmdStr = showCommandForUser cmd args
putStrLn $ "" ++ cmdStr
callCommand cmdStr

Open questions:

  • Would it make sense to run those commands in MonadReader CliEnv to use something specific for running shell commands?
@chshersh chshersh added this to the v0.0.0.0: Initial Launch milestone Jun 13, 2022
@chshersh chshersh self-assigned this Jun 13, 2022
@chshersh chshersh changed the title Add commands to run shell commands Add functions to run shell commands Jun 13, 2022
@chshersh chshersh changed the title Add functions to run shell commands Running shell commands Jun 13, 2022
@chshersh chshersh removed this from the v0.0.0.0: Initial Launch milestone Jun 13, 2022
@chshersh chshersh added the help wanted Extra attention is needed label Aug 8, 2022
@chshersh chshersh removed their assignment Mar 1, 2023
@chshersh chshersh added good first issue Good for newcomers and removed help wanted Extra attention is needed labels Mar 1, 2023
@chshersh chshersh removed the terminal label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
No open projects
Status: Todo
Development

No branches or pull requests

1 participant