module MStrap::Platform

Extended Modules

Defined in:

mstrap/platform.cr

Class Method Summary

Class Method Detail

def self.has_command?(command_name : String, skip_cache : Bool = false) : Bool #

Indicates whether the host platform has a given command available

Lookups are cached by default, but cached info can be skipped by passing skip_cache: true


[View source]
def self.install_package!(package_name : String) #

Installs a single package using the platform's package manager


[View source]
def self.install_packages!(packages : Array(String)) #

Installs a list of packages using the platform's package manager


[View source]
def self.package_installed?(package_name : String) #

Install a single package using the platform's package manager


[View source]
def self.run_command(env : Hash | Nil, command : String, args : Array(String) | Nil, shell = true, input = Process::Redirect::Inherit, output = Process::Redirect::Inherit, error = Process::Redirect::Inherit, quiet = false, sudo = false) #

Executes a given command and waits for it to complete, returning whether the exit status indicated success.

By default the process is configured with input, output, and error of the mstrap process.

  • env: optionally specifies the environment for the command
  • command: specifies the command to run. Arguments are allowed here, if args are omitted and will be evaluated by the system shell.
  • args: optionally specifies arguments for the command. These will not be processed by the shell.
  • shell: specifies whether to run the command through the system shell
  • input: specifies where to direct STDIN on the spawned process
  • output: specifies where to direct STDOUT on the spawned process
  • error: specifies where to direct STDERR on the spawned process
  • quiet: If passed as true, it does no logging. If mstrap is running in debug mode, process output is always logged.
  • sudo: specifies whether to run the command with superuser privileges

[View source]