Documentation ¶
Overview ¶
The top-level srht module is used for shared code for the CLI programs. It's not generally useful to consumers of the Go API (except, perhaps, for SrhtConfig). Most applications will use the service-specific modules from their respective subdirectories (e.g. git.sr.ht/~sircmpwn/sourcehut-go/git.sr.ht).
Index ¶
- Constants
- func NewCommandLine(args []string) (*CommandLine, *SrhtConfig)
- type CommandLine
- type Entry
- type EntryOperation
- type EntryOperationAdd
- type EntryOperationDelete
- type EntryOperationGet
- type EntryOperationUpdate
- type EntryPoint
- type SrhtClient
- func (c *SrhtClient) Delete(url string, out interface{}) error
- func (c *SrhtClient) Do(req *http.Request) (*http.Response, error)
- func (c *SrhtClient) Get(url string, out interface{}) error
- func (c *SrhtClient) Post(url string, payload interface{}, out interface{}) error
- func (c *SrhtClient) Put(url string, payload interface{}, out interface{}) error
- type SrhtConfig
- type SrhtError
- type SrhtErrorResponse
- type User
Constants ¶
const API_TIME_FORMAT = "2006-01-02T15:04:05-07:00"
const CLI_TIME_FORMAT = "Jan 2, 2006 15:04:05 UTC"
Variables ¶
This section is empty.
Functions ¶
func NewCommandLine ¶
func NewCommandLine(args []string) (*CommandLine, *SrhtConfig)
Types ¶
type CommandLine ¶
type CommandLine struct {
// contains filtered or unexported fields
}
func (*CommandLine) Run ¶
func (cli *CommandLine) Run()
func (*CommandLine) RunEntry ¶
func (cli *CommandLine) RunEntry(op int, ep *EntryPoint, args []string) error
func (*CommandLine) WithEntryPoint ¶
func (cli *CommandLine) WithEntryPoint(entry ...*EntryPoint) *CommandLine
type EntryOperation ¶
type EntryOperation interface{}
type EntryOperationAdd ¶
type EntryOperationAdd interface { EntryOperation Add(args []string) error }
type EntryOperationDelete ¶
type EntryOperationDelete interface { EntryOperation Delete(args []string) error }
type EntryOperationGet ¶
type EntryOperationGet interface { EntryOperation Get(args []string) error }
type EntryOperationUpdate ¶
type EntryOperationUpdate interface { EntryOperation Update(args []string) error }
type EntryPoint ¶
type EntryPoint struct {
// contains filtered or unexported fields
}
func NewEntryPoint ¶
func NewEntryPoint(iface EntryOperation, path ...string) *EntryPoint
type SrhtClient ¶
type SrhtClient struct {
// contains filtered or unexported fields
}
Generic container for a SourceHut API client.
func NewSrhtClient ¶
func NewSrhtClient(token string, client *http.Client) *SrhtClient
Creates a new SourceHut client with the given OAuth token and http.Client.
func (*SrhtClient) Delete ¶
func (c *SrhtClient) Delete(url string, out interface{}) error
Performs an authenticated DELETE request against a SourceHut service. The out parameter will be unmarshalled with the response.
func (*SrhtClient) Get ¶
func (c *SrhtClient) Get(url string, out interface{}) error
Performs an authenticated GET request against a SourceHut service. The out parameter will be unmarshalled with the response.
func (*SrhtClient) Post ¶
func (c *SrhtClient) Post(url string, payload interface{}, out interface{}) error
Performs an authenticated POST request against a SourceHut service. The payload parameter will be marshalled as JSON and used as the request body. The out parameter will be unmarshalled with the response.
func (*SrhtClient) Put ¶
func (c *SrhtClient) Put(url string, payload interface{}, out interface{}) error
Performs an authenticated PUT request against a SourceHut service.
type SrhtConfig ¶
type SrhtConfig struct { Config ini.File PersonalAccessToken string }
func LoadConfig ¶
func LoadConfig(path string) (*SrhtConfig, error)
"path" may be empty string to load from the default location.
type SrhtErrorResponse ¶
An error with the details of a failed API request.
func (SrhtErrorResponse) Error ¶
func (r SrhtErrorResponse) Error() string
Formats information about a failed API request as a string.