shrt

command
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2023 License: ISC Imports: 10 Imported by: 0

Documentation

Overview

usage: shrt <command> [arguments]

Shrt is a URL shortener and go-get redirector.

Shrt is a URL shortener service (much like bit.ly without the trackers) that also handles go-get requests. The latter are a specific GET request query used by the Go programming language toolchain to aid in the downloading of utilities and libraries prior to build and installation.

Upon invocation, shrt does one of two things depending on the presence or absence of the init argument. If the init argument is present, a series of questions is asked, the responses are recorded in a configuration file, and the program exits. If the init argument is absent, shrt reads the configuration and database files into memory, binds to the port specified by the -l flag, and begins serving requests.

Shortlinks are recorded in the database, and any request path not matching a shortlink is assumed to be a go-get request. This is by design, but can result in specious redirects. Additionally, subdirectory paths are not allowed.

Shortlinks generate an HTTP 301 response. Go-get requests generate an HTTP 200 response. If configured, requests to the base path (i.e., "/") generate an HTTP 302 response.

In order to add a new shortlink to the database, simply edit the file. After saving, users on Unix systems may send SIGHUP to a running server process to reload the file. Non-Unix users will need to restart the server.

The commands are:

serve   serve requests
env     print Shrt environment information
version print version information

Use "shrt help <command>" for more information about a command.

Additional topics are:

environment environment variables

Use "shrt help <topic>" for more information about that topic.

Serve requests

usage: shrt serve URL

Serve serves HTTP requests.

Shrt listens and serves shortlinks and go-get requests on the provided URL. The only recognized scheme is http.

Print Shrt environment information

usage: shrt env [-u] [-w] [var ...]

Env prints Shrt environment information.

By default env prints information as a shell script. If one or more variable names is given as arguments, env prints the value of each named variable on its own line.

The -u flag requires one or more arguments and unsets the default setting for the named environment variables, if one has been set with 'shrt env -w'.

The -w flag requires one or more arguments of the form NAME=VALUE and changes the default settings of the named environment variables to the given values. If the same NAME is provided multiple times, the last one takes effect.

For more about environment variables, see 'shrt help environment'.

Print version information

usage: version

Version prints program version information.

Version information is compliant with version 2.0.0 of the semver spec. If the version includes a pre-release identifier, build metadata is also appended to the reported version.

Environment variables

The shrt command consults environment variables for configuration. If an environment variable is unset, the shrt command uses a sensible default setting. To see the effective setting of the variable <NAME>, run 'shrt env <NAME>'. To change the default setting, run 'shrt env -w <NAME>=<VALUE>'. Defaults changed using 'shrt env -w' are recorded in a Shrt environment configuration file stored in /etc/shrt/config on Unix systems and C:\ProgramData\shrt\config on Windows. The location of the configuration file can be changed by setting the environment variable DGITENV, and 'shrt env DGITENV' prints the effective location, but 'shrt env -w' cannot change the default location. See 'shrt help env' for details.

Environment variables:

SHRTENV
	The location of the Shrt environment configuration
	file. Cannot be set using 'shrt env -w'.
SHRT_SRVNAME
	The server name of the Shrt host.
SHRT_SCMTYPE
	The SCM (or VCS) type.
SHRT_SUFFIX
	The SCM repository suffix, if required by repository
	host.
SHRT_RDRNAME
	The server name of the repository host.
SHRT_BARERDR
	Where requests with an empty path should redirect.
SHRT_DBPATH
	The absolute path to the database file.
SHRT_GOSOURCEDIR
	The string to append to the URL for go-get redirects
	to form the directory entry in the go-source meta tag.
	This key is experimental and may be removed in a
	future release.
SHRT_GOSOURCEFILE
	The string to append to the URL for go-get redirects
	to form the file entry in the go-source meta tag. This
	key is experimental and may be removed in a future
	release.

Directories

Path Synopsis
internal
base
Package base defines the foundational structures required to build out the Shrt command suite.
Package base defines the foundational structures required to build out the Shrt command suite.
env
Package env implements the "shrt env" command
Package env implements the "shrt env" command
help
Package help implements the "shrt help" command
Package help implements the "shrt help" command
serve
Package serve implements the "shrt serve" command
Package serve implements the "shrt serve" command
version
Package version implements the "shrt version" command
Package version implements the "shrt version" command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL