ヘルプとバージョン表示(CLI)の削除

このコミットが含まれているのは:
守矢諏訪子 2024-06-06 15:34:59 +09:00
コミット 6056cf6d68
9個のファイルの変更85行の追加63行の削除

ファイルの表示

@ -1,6 +1,7 @@
# 2.3.0
* GPL→ISC
* GNU Make→BSD Make
* ヘルプとバージョン表示(CLI)の削除
# 2.2.0
* ポート番号の修正

ファイルの表示

@ -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)

72
main.go
ファイルの表示

@ -9,18 +9,11 @@ import (
var sofname = "urloli"
var version = "2.3.0"
func help () {
fmt.Println(" 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> コマンドラインで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)
}
}

40
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)
}

ファイルの表示

@ -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 バグ報告

ファイルの表示

@ -1,7 +1,9 @@
{{define "footer"}}
</div>
<p class="footer">
<a href="https://gitler.moe/suwako/urloli"><img src="/static/git.png" alt="Git" /></a> |
<a href="https://gitler.moe/suwako/urloli">
<img src="/static/git.png" alt="Git" />
</a> |
<a href="https://076.moe/"></a>
</p>
</body>

ファイルの表示

@ -1,5 +1,6 @@
{{define "header"}}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
@ -17,6 +18,8 @@
<div class="body">
<p>
<a href="/">{{.T "top"}}</a> |
<a href="https://technicalsuwako.moe/blog/urloli-{{.Ves}}/">urloli-{{.Ver}}</a>
<a href="https://technicalsuwako.moe/blog/urloli-{{.Ves}}/">
urloli-{{.Ver}}
</a>
</p>
{{end}}

ファイルの表示

@ -5,7 +5,12 @@
<option value="ja"{{if eq .Lan "ja"}} selected{{end}}>日本語</option>
<option value="en"{{if eq .Lan "en"}} selected{{end}}>English</option>
</select>
<input class="langchange" type="submit" name="langchange" value="{{.T "langchange"}}" />
<input
class="langchange"
type="submit"
name="langchange"
value="{{.T "langchange"}}"
/>
</form>
</div>
<hr />

ファイルの表示

@ -1,4 +1,3 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
{{template "header" .}}
{{.T "canunderaccess"}}
<br />