diff --git a/CHANGELOG.md b/CHANGELOG.md
index 50060e3..8348e5c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# 2.3.0
* GPL→ISC
* GNU Make→BSD Make
+* ヘルプとバージョン表示(CLI)の削除
# 2.2.0
* ポート番号の修正
diff --git a/config.go b/config.go
index 2344f45..31a361b 100644
--- a/config.go
+++ b/config.go
@@ -63,7 +63,9 @@ func getconf () (Config, error) {
data, err := ioutil.ReadFile(cnf.configpath)
if err != nil {
fmt.Println("config.jsonを開けられません: ", err)
- return cnf, errors.New("コンフィグファイルは " + cnf.configpath + " に創作して下さい。")
+ return cnf, errors.New(
+ "コンフィグファイルは " + cnf.configpath + " に創作して下さい。",
+ )
}
var payload map[string]interface{}
@@ -82,7 +84,9 @@ func getconf () (Config, error) {
return cnf, errors.New("mkdirコマンドを使って、 " + payload["webpath"].(string))
}
if !checkprefix(payload["domain"].(string)) {
- return cnf, errors.New("URLは「http://」又は「https://」で始める様にして下さい。")
+ return cnf, errors.New(
+ "URLは「http://」又は「https://」で始める様にして下さい。",
+ )
}
cnf.webpath = payload["webpath"].(string)
cnf.domain = payload["domain"].(string)
diff --git a/main.go b/main.go
index cbc6c8c..8fc60bc 100644
--- a/main.go
+++ b/main.go
@@ -9,18 +9,11 @@ import (
var sofname = "urloli"
var version = "2.3.0"
-func help () {
- fmt.Println("076 URLロリ - クッソ小さいURL短縮作成ソフトだわ〜♡")
- fmt.Println("https://urlo.li/ | https://gitler.moe/suwako/urloli")
- fmt.Println("")
- fmt.Println("使い方:");
- fmt.Println("urloli -v :バージョンを表示");
- fmt.Println("urloli -s [ポート番号] :ポート番号でウェブサーバーを実行(デフォルト=9910)");
- fmt.Println("urloli -h :ヘルプを表示");
- fmt.Println("urloli :コマンドラインでURLを短縮");
+func usage() {
+ fmt.Printf("%s-%s\nusage: %s [-s port] [url]\n", sofname, version, sofname)
}
-func main () {
+func main() {
cnf, err := getconf()
if err != nil {
fmt.Println(err)
@@ -28,38 +21,33 @@ func main () {
}
args := os.Args
- if len(args) == 2 {
- if args[1] == "-v" {
- fmt.Println("urloli-" + version)
- return
- } else if args[1] == "-s" {
- serv(cnf, 9910)
- } else if args[1] == "-h" {
- help()
- return
- } else {
- if checkprefix(args[1]) {
- _, key := geturl(args[1], cnf.linkpath, true)
- if (key != "") {
- fmt.Println(cnf.domain + "/" + key)
- } else {
- fmt.Println(cnf.domain + "/" + insertjson(args[1], cnf.linkpath))
- }
- return
- } else {
- fmt.Println("URLは不正です。終了…")
- return
- }
- }
- } else if len(args) == 3 && args[1] == "-s" {
- if port, err := strconv.Atoi(args[2]); err != nil {
- fmt.Printf("%qは数字ではありません。\n", args[2])
- return
- } else {
- serv(cnf, port)
- }
- } else {
- help()
+ if len(args) < 2 {
+ usage()
return
}
+
+ if len(args) == 2 && args[1] == "-s" {
+ serv(cnf, 9910)
+ } else if len(args) == 2 && args[1] != "-s" {
+ if !checkprefix(args[1]) {
+ fmt.Println("URLは不正です。終了…")
+ return
+ }
+
+ _, key := geturl(args[1], cnf.linkpath, true)
+ if (key != "") {
+ fmt.Println(cnf.domain + "/" + key)
+ } else {
+ fmt.Println(cnf.domain + "/" + insertjson(args[1], cnf.linkpath))
+ }
+ return
+ } else if len(args) == 3 && args[1] == "-s" {
+ port, err := strconv.Atoi(args[2])
+ if err != nil {
+ fmt.Printf("%qは数字ではありません。\n", args[2])
+ return
+ }
+
+ serv(cnf, port)
+ }
}
diff --git a/srv.go b/srv.go
index 425af90..992eab6 100644
--- a/srv.go
+++ b/srv.go
@@ -62,8 +62,15 @@ func serv (cnf Config, port int) {
log.Fatal(err)
}
- http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(cnf.webpath + "/static"))))
- ftmpl := []string{cnf.webpath + "/view/index.html", cnf.webpath + "/view/header.html", cnf.webpath + "/view/footer.html"}
+ http.Handle(
+ "/static/",
+ http.StripPrefix("/static/", http.FileServer(http.Dir(cnf.webpath + "/static"))),
+ )
+ ftmpl := []string{
+ cnf.webpath + "/view/index.html",
+ cnf.webpath + "/view/header.html",
+ cnf.webpath + "/view/footer.html",
+ }
http.HandleFunc("/api", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
@@ -76,7 +83,7 @@ func serv (cnf Config, port int) {
lang := initloc(r)
i18n, err := goliblocale.GetLocale(cnf.webpath + "/locale/" + lang)
if err != nil {
- fmt.Println("liblocaleエラー:%v", err)
+ fmt.Printf("liblocaleエラー:%v", err)
return
}
@@ -103,9 +110,19 @@ func serv (cnf Config, port int) {
if chklim && chkprx {
chkfn, key := geturl(addurl, cnf.linkpath, true)
if chkfn != "" {
- res = &Api{Cod: 200, Url: cnf.domain + "/" + key, Mot: addurl, New: false}
+ res = &Api{
+ Cod: 200,
+ Url: cnf.domain + "/" + key,
+ Mot: addurl,
+ New: false,
+ }
} else {
- res = &Api{Cod: 200, Url: cnf.domain + "/" + insertjson(addurl, cnf.linkpath), Mot: addurl, New: true}
+ res = &Api{
+ Cod: 200,
+ Url: cnf.domain + "/" + insertjson(addurl, cnf.linkpath),
+ Mot: addurl,
+ New: true,
+ }
}
}
} else {
@@ -125,7 +142,7 @@ func serv (cnf Config, port int) {
i18n, err := goliblocale.GetLocale(cnf.webpath + "/locale/" + lang)
if err != nil {
- fmt.Println("liblocaleエラー:%v", err)
+ fmt.Printf("liblocaleエラー:%v", err)
return
}
data.i18n = i18n
@@ -169,7 +186,10 @@ func serv (cnf Config, port int) {
}
} else if r.PostForm.Get("langchange") != "" {
lang := r.PostForm.Get("lang")
- http.SetCookie(w, &http.Cookie{Name: "lang", Value: lang, MaxAge: 31536000, Path: "/"})
+ http.SetCookie(
+ w,
+ &http.Cookie{Name: "lang", Value: lang, MaxAge: 31536000, Path: "/"},
+ )
http.Redirect(w, r, "/", http.StatusSeeOther)
return
}
@@ -191,6 +211,10 @@ func serv (cnf Config, port int) {
data = nil
})
- fmt.Println(fmt.Sprint("http://" + cnf.ip + ":", port, " でサーバーを実行中。終了するには、CTRL+Cを押して下さい。"))
+ fmt.Println(fmt.Sprint(
+ "http://" + cnf.ip + ":",
+ port,
+ " でサーバーを実行中。終了するには、CTRL+Cを押して下さい。",
+ ))
http.ListenAndServe(fmt.Sprint(cnf.ip + ":", port), nil)
}
diff --git a/urloli.1 b/urloli.1
index 3714704..6ca175b 100644
--- a/urloli.1
+++ b/urloli.1
@@ -8,22 +8,18 @@ URLロリ - クッソ小さいURL短縮作成ソフトだわ〜♡
.PP
URLロリはクッソ小さいURL短縮作成ソフトです。
.TP
-\fB\-v\fR
-バージョンを表示
.TP
\fB\-s [ポート番号]\fR
ポート番号でサーバーを開始(デフォルト=9910)
.TP
-\fB\-h\fR
-ヘルプを表示
.TP
.B オプションなし
ローカルにURLを短縮
.SH 会話
.PP
-XMPP: xmpp:urloli@chat.xmpp.076.ne.jp?join
+XMPP: xmpp:moriyajinja@chat.xmpp.076.ne.jp?join
.br
-IRC: irc.076.ne.jp/6697 #urloli
+IRC: irc.076.moe/6697 #moriyajinja
.br
メーリングリスト: (開発中)
.SH バグ報告
diff --git a/view/footer.html b/view/footer.html
index 56a13a4..4c4b0ea 100644
--- a/view/footer.html
+++ b/view/footer.html
@@ -1,7 +1,9 @@
{{define "footer"}}
diff --git a/view/header.html b/view/header.html
index 93de3ab..be2d4b7 100644
--- a/view/header.html
+++ b/view/header.html
@@ -1,5 +1,6 @@
{{define "header"}}
-
+
diff --git a/view/submitted.html b/view/submitted.html
index 70ea277..41c1cc2 100644
--- a/view/submitted.html
+++ b/view/submitted.html
@@ -1,4 +1,3 @@
-
{{template "header" .}}
{{.T "canunderaccess"}}