Go to file
Mr. Is c17f4b38b5 💾
2016-07-28 09:44:25 -04:00
cmd 💾 2016-07-28 09:44:25 -04:00
.go-gogs-cli.example.yaml 💾 2016-07-28 07:05:34 -04:00
gogs Add created gogs remote git url as git remote. 📯 2016-07-28 09:10:55 -04:00
LICENSE.md 💾 2016-07-27 20:31:11 -04:00
main.go 💾 2016-07-27 20:11:57 -04:00
README.md 💾 2016-07-28 09:44:25 -04:00

Gogs CLI

Accesses the Gogs Client API, which is currently available exclusively on Gogs' develop branch.

Cobra & Viper go packages handle the hard work for the CLI interface.

Setup.

Clone the repo and build it yourself, or go get github.com/irstacks/go-gogs-cli. Just make sure the gogs executable winds up somewhere in your $PATH.

Oh, but how do you build it?, you ask? What path? you ask?

Ok, fine. Here's what's up. From the beginning.

With the marvelous go get...

$ go get github.com/irstacks/go-gogs-cli
$ cd $GOPATH/src/irstacks/go-gogs-cli
$ go get ./...

With the almost-as-marvelous git clone...

$ cd where/i/like/to/put/funky/things
$ git clone https://github.com/irstacks/go-gogs-cli.git
# Pedantry explained immediately below...
$ go get stuff
$ go get morestuff

Now, I say almost-as-marvelous because if you use git clone you may run into issues about your $GOPATH. It happens. Since I haven't figured out how to consistently go get all the dependencies I need for a given Go project from esoteric locations outside my $GOPATH (in part because I have so many esoteric locations and don't want to haggle with forever adjusting/amending my $GOPATH extensioners), I usually just wind up running go run main.go or go build -o gogs and go getting the dependencies it complains about one-by-one. I know, it sucks. But that's just how I roll sometimes.

Finally, we can build the sucker.

$ go build -o gogs

Here we're using -o to tell go where to build the build it makes, in this case a file in the same directory we're with the name 'gogs' (because thats a lot shorter than go-gogs-cli). Note that whatever you name this file it what it will be accessible for you as on the CLI. So if you name it 'goo' (awesome.), then your commands will be all like: $ goo repo new ...

Now here you've got some options (probably) about in which of your $PATH's paths you want to stick it. I like to keep my custom thingeys out of the dredges, so I stick mine in $HOME/bin/
... If you follow in my footsteps, make sure somewhere in your bash/fish/zsh shell you've added $HOME/bin (NO SECOND SLASH, you slashing fiend you) to your $PATH, with something like export $PATH="$PATH:$HOME/bin".

$ cp gogs ~/bin/

This repo's build is for darwin (Mac).

You can build for linux with the nifty env GOOS=linux go build -o gogs. You can probably build for Windows too but I don't trouble myself with such things.

Usage.

So far, you can do things. What's that? You can do things? Yep! Do things!

# Create basic: 
$ gogs repo create wheres-waldo # Create a repo owned by you.
# Create fancy: 
$ gogs repo create wheres-waldo --desc 'awesome stuff' --private --org GophersGophering
$ gogs repo create where-waldo -r origin
# [Aliases] for create. 
$ gogs repo [create|new|c|n]
# [Options] for create.
[-n | --name] # Name (or plain old args[0] also work, as above, obviously)
[-d | --desc] # Description
[-o | --org] # Owned by a an organization you own
[-p | --private] # Make repo private
[-r | --add-remote] # Add newly created gogs repo as a remote to your current git dir, initalizing git if necessary

# List basic:
$ gogs repo list # Get all yo repos.

# Search basic:
$ gogs repo search waldo # Search public repos for keyword 'waldo'.
# Search fancy:
$ gogs repo search waldo --limit 1 --user thatguy
# [Aliases] for search.
$ gogs repo [search|find|s|f]
# [Options] for search.
[-l | --limit] # Limit results
[-u | --user] # By user, required if you want to search private repos

# Destroy basic: 
$ gogs repo destroy irstacks my-exterminable-repo
$ gogs repo destroy irstacks/my-other-exterminable-repo
# [Aliases] for destroy.
$ gogs repo [destroy|delete|d|rid]

# Help?!
# Add --help after any command to see what's up, ie.
$ gogs --help
$ gogs repo --help
$ gogs repo create --help
# and so on...


__Oh, you're hot shit and use n > 1 Gogs?__ _Sweet_.
You can override your api and token by flagging a config file with the `--config` flag (like such) ```bash $ gogs --config="$HOME/sneaky/place/.go-gogs-cli.yaml" repo create newjunk ```
or, override your api url and token individually on the fly with flags `--token` and `--url` for any command, like so: ```bash $ gogs --url=http://some.other.company --token=qo23ransdlfknaw3oijr2323rasldf repo search waldo ```

You may have noticed that we're pretty heavy on the `gogs repo` and pretty light on the `gogs somethingelse` side of things. The [Gogs Client API](https://github.com/gogits/go-gogs-client) makes a bunch of endpoints and methods accessible for Users, Organizations, Issues, Admins, and so forth (although it's still very much a work in progress). Myself, I mostly just want to be able to create, search, and destroy like a fiend. If you would ❤️ something and are unable to help yourself, let me know by opening an issue.

Help out.

👏 [chanting] Do it! Do it! Do it!