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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
// Package text contains the text (and eventually translations) for the usql
// application.
package text
import (
"bytes"
_ "embed"
"image"
"image/png"
"regexp"
"strings"
)
// Various usql text bits.
var (
CommandName = `usql`
CommandVersion = `0.0.0-dev`
PassfileName = CommandName + `pass`
ConfigName = "config"
Banner = `the universal command-line interface for SQL databases`
CommandHelpHint = `hint: try "` + CommandName + ` --help" for more information.`
NotConnected = `(not connected)`
HelpPrefix = `help`
QuitPrefix = `quit`
ExitPrefix = `exit`
WelcomeDesc = `Type "` + HelpPrefix + `" for help.`
QueryBufferEmpty = `Query buffer is empty.`
QueryBufferReset = `Query buffer reset (cleared).`
InvalidCommand = `Invalid command \%s. Try \? for help.`
ExtraArgumentIgnored = `\%s: extra argument %q ignored`
MissingRequiredArg = `\%s: missing required argument`
Copyright = CommandName + ", " + Banner + ".\n\n" + License
RowCount = `(%d rows)`
AvailableDrivers = `Available Drivers:`
ConnInfo = `Connected with driver %s (%s)`
EnterPassword = `Enter password: `
EnterPreviousPassword = `Enter previous password: `
PasswordsDoNotMatch = `Passwords do not match, trying again ...`
NewPassword = `Enter new password: `
ConfirmPassword = `Confirm password: `
PasswordChangeFailed = `\password for %q failed: %v`
CouldNotSetVariable = `could not set variable %q`
ChartParseFailed = `\chart: invalid argument for %q: %v`
// PasswordChangeSucceeded = `\password succeeded for %q`
HelpDesc string
HelpDescShort = `Use \? for help or press control-C to clear the input buffer.`
HelpBanner = `You are using ` + CommandName + ", " + Banner + `.`
HelpCommandPrefix = `Type: `
HelpCommands = [][]string{
{`copyright`, `for distribution terms`},
//{`h`, `for help with SQL commands`},
{`?`, `for help with ` + CommandName + ` commands`},
{`g`, `or terminate with semicolon to execute query`},
{`q`, `to quit`},
}
QuitDesc = `Use \q to quit.`
UnknownFormatFieldName = `unknown option: %s`
FormatFieldInvalid = `unrecognized value %q for "%s"`
FormatFieldInvalidValue = `unrecognized value %q for "%s": %s expected`
FormatFieldNameSetMap = map[string]string{
`border`: `Border style is %d.`,
`columns`: `Target width is %d.`,
`expanded`: `Expanded display is %s.`,
`expanded_auto`: `Expanded display is used automatically.`,
`fieldsep`: `Field separator is %q.`,
`fieldsep_zero`: `Field separator is zero byte.`,
`footer`: `Default footer is %s.`,
`format`: `Output format is %s.`,
`linestyle`: `Line style is %s.`,
`locale`: `Locale is %q.`,
`null`: `Null display is %q.`,
`numericlocale`: `Locale-adjusted numeric output is %s.`,
`pager`: `Pager usage is %s.`,
`pager_min_lines`: `Pager won't be used for less than %d line(s).`,
`recordsep`: `Field separator is %q.`,
`recordsep_zero`: `Record separator is zero byte.`,
`tableattr`: `Table attributes are %q.`,
`time`: `Time display is %s.`,
`title`: `Title is %q.`,
`tuples_only`: `Tuples only is %s.`,
`unicode_border_linestyle`: `Unicode border line style is %q.`,
`unicode_column_linestyle`: `Unicode column line style is %q.`,
`unicode_header_linestyle`: `Unicode header line style is %q.`,
}
FormatFieldNameUnsetMap = map[string]string{
`tableattr`: `Table attributes unset.`,
`title`: `Title is unset.`,
}
TimingSet = `Timing is %s.`
TimingDesc = `Time: %0.3f ms`
InvalidValue = `invalid -%s value %q: %s`
NotSupportedByDriver = `%s not supported by %s driver`
RelationNotFound = `Did not find any relation named "%s".`
InvalidOption = `invalid option %q`
NotificationReceived = `Asynchronous notification %q %sreceived from server process with PID %d.`
NotificationPayload = `with payload %q `
UnknownShortAlias = `(unk)`
InvalidNamedConnection = `warning: named connection %q was not defined: %v`
ChartsPathDoesNotExist = `warning: charts_path %q does not exist`
ChartsPathIsNotADirectory = `warning: charts_path %q is not a directory`
UsageTemplate = `Usage:
{{.UseLine}}
Arguments:
DSN database url or connection name
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}
`
ChartUsage = `\chart: create and display charts from SQL data
usage: \chart [opts]
available options:
help
title [title] chart title
subtitle [subtitle] chart subtitle
size NxN chart size (width x height)
bg [color] chart background color
type [bar|line] chart type
prec [num] data decimal precision
file [path] write chart to file (svg)`
)
func init() {
// setup help description
cmds := make([]string, len(HelpCommands))
for i, h := range HelpCommands {
cmds[i] = `\` + h[0] + " " + h[1]
}
HelpDesc = HelpBanner +
"\n" + HelpCommandPrefix +
strings.Join(cmds, "\n"+strings.Repeat(" ", len(HelpCommandPrefix)))
}
var spaceRE = regexp.MustCompile(`\s+`)
// Command returns the command name without spaces.
var Command = func() string {
return spaceRE.ReplaceAllString(CommandName, "")
}
// CommandLower returns the lower case command name without spaces.
var CommandLower = func() string {
return strings.ToLower(Command())
}
// CommandUpper returns the upper case command name without spaces.
var CommandUpper = func() string {
return strings.ToUpper(Command())
}
// Short returns the command name and banner.
var Short = func() string {
return Command() + ", " + Banner
}
// Logo is the logo.
var Logo image.Image
// LogoPng is the embedded logo.
//
//go:embed logo.png
var LogoPng []byte
func init() {
var err error
if Logo, err = png.Decode(bytes.NewReader(LogoPng)); err != nil {
panic(err)
}
}
|