Skip to content

Add common interface for pquery #4

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

Open
8 tasks
hololeap opened this issue May 5, 2025 · 0 comments
Open
8 tasks

Add common interface for pquery #4

hololeap opened this issue May 5, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@hololeap
Copy link
Member

hololeap commented May 5, 2025

This is being used in various places, such as revdep-scanner.

A new subproject inside the cabal-portage project is a good place for this (gentoo-utils?). It should include:

  • A common interface for running commands

    • A re-worked runOpaque using the common error-handling interface

    • A re-worked runTransparent using the common error-handling interface

    • A common interface for handling errors (just an example):

      -- exits with a RunProcessException or else returns captured stdout and stderr
      tryProcess -- better name?
          :: Exception e
          -- Nothing is passed to stdin
          => Maybe (ConduitT ByteString ByteString IO ()) -- extra stuff using stdout (useful for e.g. runTransparent)
          -> Maybe (ConduitT ByteString ByteString IO ()) -- extra stuff using stderr (useful for e.g. runTransparent)
          -> Maybe (ExitCode -> Lazy.Text -> Lazy.Text -> IO (Maybe RunProcessException)) -- tweak exception throwing
          -> CreateProcess -- command to run, arguments, and extra settings
          -> IO (Either RunProcessException (Lazy.Text, Lazy.Text))
      
      data RunProcessException = RPE
          { rpeCP :: CreateProcess
          , rpeExitCode :: ExitCode
          , rpeStdout :: Lazy.Text
          , rpeStderr :: Lazy.Text
          }
    • Should handle errors by displying the command that was run, the exit code, the captured stdout, and the captured stderr, along with any other exceptions thrown.

  • Convenience functions for running common commands, such as pquery, eix, and emerge

  • Convenience functions for running pquery and parsing the output to e.g. HashMaps

  • Orphan instances for portage-hs types (e.g. Hashable) to keep its dependency footprint low

@hololeap hololeap added the enhancement New feature or request label May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant