This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
option.clj
47 lines (41 loc) · 2.06 KB
/
option.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(ns com.agilecreativity.gh_utils.option
(:require [clojure.string :as str]))
(def default-config "~/Dropbox/config/github.edn")
(def default-remote-label "origin")
(def options
[["-c" "--config CONFIG" :default default-config]
["-r" "--repo REPO"]
["-i" "--init-commit"]
["-l" "--remote-label REMOTE_LABEL" :default default-remote-label]
["-p" "--push"]
["-h" "--help"]])
(defn usage [summary]
(str/join \newline ["Create new Github's project from a command line"
""
"Usage: gh-utils [options]"
summary
""
"Options:"
""
"--config CONFIG full path to the config file e.g. ~/Dropbox/config/github.edn"
"--init-commit run git-init and git commit on the local project"
"--repo REPO name of repository to be created"
"--remote-label REMOTE_LABEL remote label default to 'origin'"
"--push push the code to the remote repository as well"
""
"Examples:"
""
"a) To push existing project that have already contain some commit (e.g. skip -i)"
"$gh-utils -c ~/Dropbox/config/github.edn -r awesome-idea -l upstream -p"
""
"b) To create and push brand new project to Github and run initial commit"
"$gh-utils -c ~/Dropbox/config/github.edn -r awesome-idea -i -l origin -p"
""
"c) To create brand new project to Github, run initial commit and skip pushing to remote branch."
"$gh-utils -c ~/Dropbox/config/github.edn -r awesome-idea -i -l origin"]))
(defn error-message [errors]
(str "The following error occured while parsing your commands: \n\n"
(str/join \newline errors)))
(defn exit [status msg]
(println msg)
(System/exit status))