Method: Makit::Commands::Request.from_string

Defined in:
lib/makit/commands/request.rb

.from_string(command_string, **options) ⇒ Request

Create a request from a shell command string.

Examples:

Request.from_string("git clone https://github.com/user/repo.git")
Request.from_string("bundle install --jobs 4")

Parameters:

  • command_string (String)

    shell command string to parse

  • options (Hash)

    additional options

Returns:

Raises:

  • (ArgumentError)

    if command string is invalid



113
114
115
116
117
118
119
120
121
122
# File 'lib/makit/commands/request.rb', line 113

def self.from_string(command_string, **options)
  raise ArgumentError, "Command string cannot be empty" if command_string.nil? || command_string.strip.empty?

  # Parse shell command string into command and arguments
  parts = Shellwords.split(command_string.strip)
  command = parts.shift
  arguments = parts

  new(command: command, arguments: arguments, **options)
end