github.com/krzko/gosh@v0.0.0-20241128233202-5abd4ef06633/internal/shell/builtins/http.go (about) 1 // internal/shell/builtins/http.go 2 package builtins 3 4 import ( 5 "fmt" 6 ) 7 8 // HttpCommand represents the 'http' builtin command. 9 type HttpCommand struct{} 10 11 // Execute performs an HTTP GET request to the specified URL. 12 // Usage: http [URL] 13 func (c *HttpCommand) Execute(args []string) error { 14 if len(args) == 0 { 15 return fmt.Errorf("URL required") 16 } 17 18 rawURL := args[0] 19 if err := executeRequest(rawURL, "http"); err != nil { 20 return err 21 } 22 23 return nil 24 } 25 26 // Help returns the help message for the 'http' command. 27 func (c *HttpCommand) Help() string { 28 return `http: Transfer data from a URL using HTTP 29 Usage: http [URL] 30 31 If the scheme (http:// or https://) is omitted, 'http://' is assumed.` 32 }