class GitLab
- GitLab
- Reference
- Object
Overview
This class provides
- a client for interacting with a GitLab server (REST and GraphQL)
- types to represent and work with GitLab objects
- methods for working with the current working directory
- an OptionParser for running a command-line application
- a HTTP::Handler for running a proxy service
Defined in:
gitlab.crgitlab/option_parser.cr
Constant Summary
-
VERSION =
"0.0.2" -
The version of the module.
Constructors
-
.git(name : String) : self
Makes a new GitLab using values from the git configuration under name, falling back to CI environment variables or defaults.
-
.new(uri : URI = @@uri, token : -> String = @@token, home : Path = @@home, user : String = @@user)
Makes a new GitLab which can fetch request from uri using the result of calling token, and treats home as the root of its project tree.
Class Method Summary
-
.expand_short_options(args : Array(String), op : OptionParser | Nil = nil) : Array(String)
Expands combined short options (e.g., "-qt" becomes ["-q", "-t"]).
-
.parse_assignments(args : Array(String), into : Hash(String, String)) : Hash(String, String)
Parses an array of "KEY=VALUE" assignment strings into a Hash(String, String).
-
.parse_assignments(args : Array(String), into : Hash(String, Array(String))) : Hash(String, Array(String))
Parses an array of "KEY=VALUE" assignment strings into a Hash(String, Array(String)).
- .version
Instance Method Summary
- #config(path = ".")
-
#delete(resource)
Deletes a resource.
-
#done=(done : Bool)
Flag to indicate a terminal command (--help, --version) was handled.
-
#done? : Bool
Flag to indicate a terminal command (--help, --version) was handled.
- #error : IO
- #error=(error : IO)
-
#get(resource, form = {} of String => Array(String))
Gets a resource.
-
#home : Path
The home path used to create the workdir tree manager
-
#input : IO
IO streams for CLI output (allows testing by injecting IO::Memory).
-
#input=(input : IO)
IO streams for CLI output (allows testing by injecting IO::Memory).
-
#mutation(query, values = {} of String => String)
Queries GraphQL with a mutation
-
#namespace?(path = ".") : String | Nil
Returns the namespace path if the given path is within home but not a project (i.e., a directory under home that doesn't have a .git folder).
- #option_parser
- #output : IO
- #output=(output : IO)
-
#patch(resource, body : String | Bytes | IO | Nil)
Modifies a resource.
-
#patch(resource, body)
Modifies a resource.
-
#post(collection, body : String | Bytes | IO | Nil)
Creates a new resource.
-
#post(collection, body)
Creates a new resource.
-
#project?(path = ".")
Returns a Project if the given Path is inside a git working tree (searching upward, like git itself does).
-
#put(resource, body : String | Bytes | IO | Nil)
Sets a resource.
-
#put(resource, body)
Sets a resource.
-
#query(query, values = {} of String => String)
Queries GraphQL (with a query)
-
#run(args : Array(String), input : IO = STDIN, output : IO = STDOUT, error : IO = STDERR) : Int32
Runs the CLI with the given arguments, returning an exit code.
-
#token : -> String
The token proc used to create the client
-
#token=(token : -> String)
The token proc used to create the client
-
#uri : URI
The URI used to create the client
-
#user : String
The username used to identify the user's branch of the workdir tree manager
Constructor Detail
Makes a new GitLab using values from the git configuration under name, falling back to CI environment variables or defaults.
Makes a new GitLab which can fetch request from uri using the result of calling token, and treats home as the root of its project tree.
Class Method Detail
Expands combined short options (e.g., "-qt" becomes ["-q", "-t"]). Long options and single short options are passed through unchanged. If an OptionParser is provided, it will be used to determine which flags take arguments (e.g., "-ofile" becomes ["-o", "file"] if -o takes a value).
Parses an array of "KEY=VALUE" assignment strings into a Hash(String, String). If a key appears more than once, the last value wins.
Parses an array of "KEY=VALUE" assignment strings into a Hash(String, Array(String)). Values are accumulated, so repeated keys produce multiple entries.
Instance Method Detail
Queries GraphQL with a mutation
Returns the namespace path if the given path is within home but not a project (i.e., a directory under home that doesn't have a .git folder).
Returns a Project if the given Path is inside a git working tree (searching upward, like git itself does).
Runs the CLI with the given arguments, returning an exit code.