]> Cypherpunks.ru repositories - gocheese.git/blobdiff - usage.go
Refactor -help, remove -root
[gocheese.git] / usage.go
diff --git a/usage.go b/usage.go
new file mode 100644 (file)
index 0000000..3959d6a
--- /dev/null
+++ b/usage.go
@@ -0,0 +1,94 @@
+/*
+GoCheese -- Python private package repository and caching proxy
+Copyright (C) 2019-2021 Sergey Matveev <stargrave@stargrave.org>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 3 of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package main
+
+import (
+       "fmt"
+       "os"
+)
+
+const (
+       DefaultBind             = "[::]:8080"
+       DefaultMaxClients       = 128
+       DefaultNoRefreshURLPath = "/norefresh/"
+       DefaultRefreshURLPath   = "/simple/"
+       DefaultGPGUpdateURLPath = "/gpgupdate/"
+       DefaultJSONURLPath      = "/pypi/"
+       DefaultPyPIURL          = "https://pypi.org/simple/"
+       DefaultJSONURL          = "https://pypi.org/pypi/"
+
+       Warranty = `This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 3 of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.`
+)
+
+func usage() {
+       fmt.Fprintf(os.Stderr, `Usage: gocheese [OPTIONS ...] /path/to/packages
+
+Network transport options:
+  -ucspi          -- Work as UCSPI-TCP service instead of listening
+  -bind HOST:PORT -- TCP address to bind to (default: %s)
+  -maxclients N   -- Maximal amount of simultaneous clients (default: %d)
+
+TLS enabling options:
+  -tls-cert PEM -- Path to TLS X.509 certificate
+  -tls-key PEM  -- Path to TLS X.509 private key
+
+HTTP endpoints:
+  -norefresh URLPATH -- Non-refreshing Simple API path (default: %s)
+  -refresh URLPATH   -- Auto-refreshing Simple API path (default: %s)
+  -gpgupdate URLPATH -- GPG forceful refreshing path (default: %s)
+  -json URLPATH      -- JSON API path (default: %s)
+
+Upstream PyPI:
+  -pypi URL      -- Upstream Simple API (default: %s)
+  -pypi-json URL -- Enable and use specified JSON API (default: %s)
+                    Disabled if empty.
+  -pypi-cert-hash HEX(SHA256(SPKI)) -- Authenticate upstream by its
+                                       X.509 certificate's hash
+Password management:
+  -passwd PATH      -- Path to readable FIFO for loading passwords
+  -passwd-list PATH -- Path to writeable FIFO for listing logins
+  -passwd-check     -- Verify passwords format from stdin, then exit
+
+Other options:
+  -log-timestamped -- Prepend timestamp to log messages
+  -fsck            -- Run integrity check of all packages
+  -version         -- Print version information
+  -warranty        -- Print warranty information
+
+GOCHEESE_NO_SYNC=1 environment variable disable filesystem fsyncs.
+`,
+               DefaultBind,
+               DefaultMaxClients,
+               DefaultNoRefreshURLPath,
+               DefaultRefreshURLPath,
+               DefaultGPGUpdateURLPath,
+               DefaultJSONURLPath,
+               DefaultPyPIURL,
+               DefaultJSONURLPath,
+       )
+}