Permalink
Browse files

Updated to new plugin format. At least it compiles.

  • Loading branch information...
1 parent e419c4e commit ccf5ed657d5e84b8c46b0c0b9cddcc2a441d16b2 @Raynes committed Oct 13, 2011
View
@@ -2,21 +2,11 @@
cake-github is a [cake](http://github.com/ninjudd/cake) plugin for providing an interface to the github API from your command-line.
-Have you ever desired to create a new Github repository immediately after creating your project, without having to switch to your web browser and travel to github.com to do so? Desire no longer!
+Have you ever wanted to create a new Github repository immediately after creating your project without having to switch to your web browser and navigate to github.com to do so? This might be useful for you.
-The plugin will provide an interface to all, or most of the API. You'll be able to create, delete, search, and modify repositories, all from your terminal with cake. And that isn't even the beginning.
+The plugin will provide an interface to all, or most of the API. You'll be able to create, delete, search, and modify repositories, all from your terminal with cake.
-## gotmilk
-
-This plugin is basically the evolution of gotmilk. Gotmilk is deprecated (pretty sure nobody used it anyway) from this point foreward. Since there are already excellent command-line tools for github, and the JVM startup time is too significant for gotmilk to ever be practical, there is no use in it continuing.
-
-This plugin is much more ambitious than gotmilk. Since cake already provides a persistent JVM, startup time is no longer a problem. Couple that with the fact that the target audience is Clojure users anyway, I think integration with cake as a cake plugin will be better in the long run.
-
-Here is a brief, and incomplete list of improvements that cake-github has over gotmilk:
-
-* Cake's persistent JVM means no JVM startup time.
-* Enhanced (sane) formatting of API call results. It actually looks like a decent command-line tool now.
-* Integrated into the worlds tastiest build tool.
+So, what does this have over the official Github command-line tool? Well, it's integrated with cake and written in Clojure. Mostly the integrated with cake part that matters. If you're already using cake, you've got everything you need. Just add this plugin to your global project and off you go.
# Usage
View
@@ -1,7 +1,5 @@
-(defproject cake-github "0.1.0"
+(defproject cake-github "0.2.0-alpha1"
:description "A cake plugin providing a command-line interface to the Github API."
- :dependencies [[clojure "1.2.0"]
- [clj-github "1.0.0-SNAPSHOT"]]
- :dev-dependencies [[swank-clojure "1.2.1"]
- [clj-github "1.0.0-SNAPSHOT"]]
- :tasks [cake-github.tasks])
+ :dependencies [[clojure "1.3.0"]
+ [clj-github "1.1.0-alpha1"]]
+ :cake-plugins [[cake-github "0.2.0-alpha1"]])
View
@@ -0,0 +1,35 @@
+(ns cake.tasks.gists
+ (:use cake cake.core
+ cake-github.core
+ clj-github.gists))
+
+(ts
+ gists
+ "Stuff for gisting."
+
+ (deftask new
+ "Gist a file. Pass in the path to the file relative to where this task is called."
+ (format-result
+ (str
+ "http://gist.github.com/"
+ (:repo
+ (let [gist-file ((:gists.new *opts*) 0)]
+ (new-gist auth
+ (last (.split gist-file "/"))
+ (slurp (str (System/getProperty "user.dir") "/" gist-file))))))))
+
+ (deftask contents
+ "Show the contents of a gist. Pass in the id of the gist and the file name."
+ {[one two] :gists.contents}
+ (format-result (show-gist one two)))
+
+ (deftask show
+ "Show metadata for another user's gists. Pass in the name of the user. Pass in --results
+ to limit results. The default limit is three."
+ (format-result
+ (show-users-gists ((:gists.show *opts*) 0))
+ :map-type :gist :max (:results *opts*)))
+
+ (deftask meta
+ "Show a gist's metadata. Pass in the gist's ID."
+ (format-result (show-gist-meta ((:gists.meta *opts*) 0)) :map-type :gist)))
@@ -0,0 +1,4 @@
+(ns cake.tasks.github
+ (:use [cake.core :only [require-tasks]]))
+
+(require-tasks [cake.tasks issues users repos gists])
View
@@ -0,0 +1,76 @@
+(ns cake.tasks.issues
+ (:use cake cake.core
+ cake-github.core
+ clj-github.issues))
+
+(ts
+ issues
+ "Tasks for doing stuff with issues."
+
+ (deftask open
+ "Open an issue. Pass in the owner of the repo, name of the repo,
+ title of the issue, and body of the issue."
+ {[one two three four] :issues.open}
+ (format-result (open-issue one two three four) :map-type :issue))
+
+ (deftask info
+ "Show data about an issue. Pass in the owner of the repo, name of the repo,
+ and number of the issue."
+ {[one two three] :issues.info}
+ (format-result (show-issue one two three) :map-type :issue))
+
+ (deftask close
+ "Close an issue. Pass in the owner of the repo, name of the repo, and issue number."
+ {[one two three] :issues.close}
+ (format-result (close-issue one two three) :map-type :issue))
+
+ (deftask comment
+ "Comment on an issue. Pass in the owner of the repo, name of the repo, issue number,
+ and the comment you want to add."
+ {[one two three four] :issues.comment}
+ (format-result (comment-issue one two three four) :map-type :comment))
+
+ (deftask tag
+ "Add a label to an issue or the system. Pass in the owner of the repo, name of the repo,
+ the label you want to add, and the number of the issue or no number if you're adding
+ the label to the system rather than to an issue."
+ {[one two three four] :issues.tag}
+ (format-result (add-label one two three four)))
+
+ (deftask untag
+ "Remove a label from an issue or the system. Pass in the owner of the repo, name of the repo,
+ the label you want to remove, and the number of the issue or no number if you're removing
+ the label from the system rather than from an issue."
+ {[one two three four] :issues.untag}
+ (format-result (remove-label one two three four)))
+
+ (deftask tags
+ "Show the tags on a repo. Pass in the owner and name of the repo."
+ {[one two] :issues.tags}
+ (format-result (list-labels one two)))
+
+ (deftask comments
+ "List the comments on an issue. Pass in the owner of the repo, name of the repo,
+ and the number of the issue. You can limit results with --results. The default limit
+ is three."
+ {[one two three] :issues.comments results :results}
+ (format-result (issue-comments one two three) :map-type :comment :max results))
+
+ (deftask show
+ "Show info about a repo's issues. Pass in the owner and name of the repo, and either
+ 'open' or 'closed'. Limit results with --results. The default limit is three."
+ {[one two three] :issues.show results :results}
+ (format-result (list-issues one two three) :map-type :issue :max results))
+
+ (deftask reopen
+ "Reopen a previously closed issue. Pass in the owner and name of the repo, and the issue
+ number."
+ {[one two three] :issues.reopen}
+ (format-result (reopen-issue one two three) :map-type :issue))
+
+ (deftask issues.search
+ "Search through issues. Pass in the owner and name of the repo, the state of the issues
+ you want to search (either 'open' or 'closed') and the search term. Limit results with
+ --results. Default limit is three."
+ {[one two three four] :issues.search results :results}
+ (format-result (search-issues one two three four) :map-type :issue :max results)))
View
@@ -0,0 +1,129 @@
+(ns cake.tasks.repos
+ (:use cake cake.core
+ cake-github.core
+ clj-github.repos))
+
+(ts
+ repos
+ "Tasks for doing stuff with repositories."
+
+ (deftask show
+ "Display information about repositories that a user has. Pass the username
+ of the user you'd like to stalk. You can optionally pass --results to limit
+ the number of results shown. The default limit is three. "
+ (format-result (show-repos ((:repos.show *opts*) 0))
+ :max (:results *opts*) :generate-clone-urls true))
+
+ (deftask search
+ "Search for repos on github. Pass in the query string. You can optionally pass
+ --results to limit results, default being three.
+ Optionally supply --language and --start-page to narrow results."
+ (format-result
+ (apply search-repos ((:repos.search *opts*) 0)
+ (format-options *opts* :repos.search :results))
+ :max (:results *opts*) :generate-clone-urls true))
+
+ (deftask create
+ "Create a repo. Pass in the name of the repository. Optionally pass --description,
+ --homepage, and --public=[true|false]"
+ (format-result
+ (apply create-repo ((:repos.create *opts*) 0)
+ (format-options *opts* :repos.create))
+ :generate-clone-urls true))
+
+ (deftask delete
+ "Delete a repo. This cannot be undone. Use wisely. Pass in the name of the repo."
+ (format-result (delete-repo ((:repos.delete *opts*) 0))))
+
+ (deftask fork
+ "Fork a repo. Pass in the owner of the repo you want to fork and the name of the repo."
+ {[one two] :repos.fork}
+ (format-result (fork-repo one two) :generate-clone-urls true))
+
+ (deftask set
+ "Set information about a repo. Pass in the owner of the repo, the name of the repo,
+ the key corresponding to the information you want to change, and the value you want
+ to set it to. Possible keys are description, homepage, has_wiki, has_downloads,
+ and has_issues."
+ {[one two three four] :repos.set}
+ (format-result (set-repo-info one two three four)))
+
+ (deftask info
+ "Get infomation about a repository. Pass in the owner of the repo and the name of the repo."
+ {[one two] :repos.info}
+ (format-result (show-repo-info one two)))
+
+ (deftask watch
+ "Watch a repo. Pass in the owner of the repo and the name of the repo."
+ {[one two] :repos.watch}
+ (format-result (watch-repo one two)))
+
+ (deftask unwatch
+ "Unwatch a repo. Pass in the owner of the repo and the name of the repo."
+ {[one two] :repos.unwatch}
+ (format-result (unwatch-repo one two)))
+
+ (deftask tags
+ "List the tags on a repo. Pass in the owner of the repo and it's name."
+ {[one two] :repos.tag}
+ (format-result (show-tags one two) :map-type :generic))
+
+ (deftask pushable
+ "List all the repos that you don't own that you can push to. Limit results with --results.
+ the default limit is three."
+ (format-result (show-pushable auth) :max (:results *opts*)))
+
+ (deftask network
+ "Show a repository's full network. Pass in the owner and name of the repository.
+ Limit results with --results. The default limit is three."
+ {[one two] :repos.network results :results}
+ (format-result (show-network one two) :max results))
+
+ (deftask languages
+ "List the languages used in a project. Values are in bytes. Limit results with --results.
+ The default limit is three."
+ {[one two] :repos.languages results :results}
+ (format-result (show-languages one two) :max results :map-type :generic))
+
+ (deftask contributors
+ "List everybody who has contributed to a repo, including non-github-users.
+ Pass the owner and name of the repository. Limit results with --results. Default limit is three."
+ {[one two] :repos.contributors results :results}
+ (format-result (show-contributors one two) :map-type :user :max results))
+
+ (deftask collaborators
+ "List collaborators on a repo. Pass the owner and name of the repo."
+ {[one two] :repos.collaborators}
+ (format-result (show-collaborators one two)))
+
+ (deftask add-collaborator
+ "Add a collaborator to your Github repository. Pass in the username you want to add and the
+ name of the repo."
+ {[one two] :repos.add-collaborator}
+ (format-result (add-collaborator one two)))
+
+ (deftask rm-collaborator
+ "Remove a collaborator from your Github repository. Pass in the username you want to remove
+ and the name of the repo."
+ {[one two] :repos.rm-collaborator}
+ (format-result (remove-collaborator one two)))
+
+ (deftask deploy
+ "List the deploy keys for a repository. Pass in the name of the repo."
+ (format-result (show-deploy-keys ((:repos.deploy *opts*) 0))))
+
+ (deftask add-deploy
+ "Add a deploy key to a repository. Pass in the name of the repository, title of the key
+ and the key itself."
+ {[one two three] :repos.add-deploy}
+ (format-result (add-deploy-key one two three)))
+
+ (deftask rm-deploy
+ "Remove a deploy key from a repository. Pass in the name of the repo and the title of the key."
+ {[one two] :repos.rm-deploy}
+ (format-result (remove-deploy-key one two)))
+
+ (deftask visibility
+ "Set a repository's visibility. Pass in the name of the repo and either 'public' or 'private'."
+ {[one two] :repos.visibility}
+ (format-result (set-repo-visibility one two))))
View
@@ -0,0 +1,46 @@
+(ns cake.tasks.users
+ (:use cake cake.core
+ cake-github.core
+ clj-github.users))
+
+(ts
+ users
+ "Tasks for doing stuff with users."
+ (deftask follow
+ "Follow a user. Pass in the name of the user you want to follow."
+ (format-result (follow ((:users.follow *opts*) 0))))
+
+ (deftask unfollow
+ "Unfollow a user. Pass in the name of the user you want to unfollow."
+ (format-result (unfollow ((:users.unfollow *opts*) 0))))
+
+ (deftask search
+ "Search users. Pass in the query string. Optionally pass --results to limit results.
+ Default is three."
+ (format-result
+ (search-users ((:users.search *opts*) 0)) :map-type :user :max (:results *opts*)))
+
+ (deftask followers
+ "Find out what users are following a user. Pass in the user."
+ (format-result (show-followers ((:users.followers *opts*) 0))))
+
+ (deftask following
+ "Find out what users another user is following. Pass in the user."
+ (format-result (show-following ((:users.following *opts*) 0))))
+
+ (deftask info
+ "View detailed information about a user. Pass in the name of the user."
+ (format-result (show-user-info ((:users.info *opts*) 0)) :map-type :user))
+
+ (deftask watching
+ "Find out what repos a user is watching. Pass in the name of the user. Optionally
+ pass --results to limit results. Default is three."
+ (format-result
+ (show-watching ((:users.watching *opts*) 0))
+ :map-type :repo :max (:results *opts*)))
+
+ (deftask set
+ "Set information about a user. Pass in the username, a key, and a value to set that key
+ to. Possible keys are name, email, blog, company, and location."
+ {[one two three] :users.set}
+ (format-result (set-user one two three) :map-type :user)))
View
@@ -1,5 +1,6 @@
(ns cake-github.core
- (:use [clojure.java.shell :only [sh]]))
+ (:use [clojure.java.shell :only [sh]]
+ [clj-github.core :only [with-auth]]))
(def line "\n-------------------------------------------\n")
@@ -120,5 +121,9 @@
maps))))
(format-result-helper (if generate-clone-urls (clone-urls x) x) map-type))))
+(defmacro format-api [& body]
+ `(with-auth auth
+ (format-result ~@body)))
+
(defn options [opts & options]
(some opts options))
View
@@ -1,32 +0,0 @@
-(ns cake-github.gists
- (:use cake cake.core
- cake-github.core
- clj-github.gists)
- (:import java.awt.Toolkit))
-
-(deftask gists.new
- "Gist a file. Pass in the path to the file relative to where this task is called."
- (format-result
- (str
- "http://gist.github.com/"
- (:repo
- (let [gist-file ((:gists.new *opts*) 0)]
- (new-gist auth
- (last (.split gist-file "/"))
- (slurp (str (System/getProperty "user.dir") "/" gist-file))))))))
-
-(deftask gists.contents
- "Show the contents of a gist. Pass in the id of the gist and the file name."
- {[one two] :gists.contents}
- (format-result (show-gist auth one two)))
-
-(deftask gists.show
- "Show metadata for another user's gists. Pass in the name of the user. Pass in --results
- to limit results. The default limit is three."
- (format-result
- (show-users-gists auth ((:gists.show *opts*) 0))
- :map-type :gist :max (:results *opts*)))
-
-(deftask gists.meta
- "Show a gist's metadata. Pass in the gist's ID."
- (format-result (show-gist-meta auth ((:gists.meta *opts*) 0)) :map-type :gist))
Oops, something went wrong.

0 comments on commit ccf5ed6

Please sign in to comment.