diff --git a/README.md b/README.md
index 45eaa97..e52b0d5 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ It speaks the same format as the web app, so links work in both directions: a li
```bash
secretli share # type or paste the secret, then Ctrl-D
pbpaste | secretli share -e 1h # text from a pipe, gone after an hour
-secretli share --paste -c # the clipboard's text in, the link back on the clipboard
+secretli share --from-clipboard -c # the clipboard's text in, the link back on the clipboard
secretli share deploy.key notes.pdf # files; -p adds a password, --reusable lets it open more than once
secretli open # text to stdout, files to the current directory; -c copies text instead
secretli status # what a link points to, without opening it
@@ -58,7 +58,7 @@ For shell completion without Homebrew, `secretli completion zsh --help` (or `bas
## Use
-**Sharing.** Files are arguments; text comes from a pipe, from a prompt when you are at a terminal, from the clipboard with `--paste`, or from `-t`. The prompt, the pipe and the clipboard keep the secret out of your shell history; `-t` does not. `--paste` leaves off the clipboard's final line break, as `open --copy` does, and with `--name` shares the clipboard as a file; it works with the same clipboard tools as `--copy`. `-` shares stdin as a file named by `--name`:
+**Sharing.** Files are arguments; text comes from a pipe, from a prompt when you are at a terminal, from the clipboard with `--from-clipboard`, or from `-t`. The prompt, the pipe and the clipboard keep the secret out of your shell history; `-t` does not. `--from-clipboard` leaves off the clipboard's final line break, as `open --to-clipboard` does, and with `--name` shares the clipboard as a file; it works with the same clipboard tools as `--to-clipboard`. `-` shares stdin as a file named by `--name`:
```bash
pg_dump db | gzip | secretli share --name db.sql.gz
@@ -68,15 +68,15 @@ Links open once and expire after a day unless you say otherwise: `-e` takes `5m`
Every share prints two links: the one to hand out, and the owner link, which can delete the secret and, for a reusable one, tells you whether it has been opened. Keep the owner link to yourself.
-**Opening.** Text goes to stdout exactly as it was shared. At a terminal, control characters in it, which could steer the terminal, show as `�`, and the command says so; a pipe, a file or `--copy` gets the exact text. File names and error messages from the server reach the terminal without control characters or direction overrides either. Files are saved to the current directory or to `--out`, and nothing is overwritten unless you pass `--force`; `--stdout` streams a single file instead. When a file of that name exists, a reusable secret is refused before anything is saved, and you can open it again elsewhere; a one-time secret, used up by then, saves that file as `name (2).ext`, or the next number free, and says so. A file's name is made safe first: no path, no control characters, no names Windows reserves for devices, at most 255 bytes. Two files of one secret with the same name are both saved, the second as `name (2).ext`, and the command says so. `--force` replaces a file that exists with a new one, so a link in its place is replaced, never followed. Before anything is opened, the command says what the link points to. Opening a one-time secret uses it up, so for one of those it asks first, and Enter means no; `-y`/`--yes` opens it without asking. Reusable secrets open right away. Without an argument the link is read from stdin, or asked for without showing what you paste, which keeps it out of your shell history and the scrollback too.
+**Opening.** Text goes to stdout exactly as it was shared. At a terminal, control characters in it, which could steer the terminal, show as `�`, and the command says so; a pipe, a file or `--to-clipboard` gets the exact text. File names and error messages from the server reach the terminal without control characters or direction overrides either. Files are saved to the current directory or to `--out`, and nothing is overwritten unless you pass `--force`; `--stdout` streams a single file instead. When a file of that name exists, a reusable secret is refused before anything is saved, and you can open it again elsewhere; a one-time secret, used up by then, saves that file as `name (2).ext`, or the next number free, and says so. A file's name is made safe first: no path, no control characters, no names Windows reserves for devices, at most 255 bytes. Two files of one secret with the same name are both saved, the second as `name (2).ext`, and the command says so. `--force` replaces a file that exists with a new one, so a link in its place is replaced, never followed. Before anything is opened, the command says what the link points to. Opening a one-time secret uses it up, so for one of those it asks first, and Enter means no; `-y`/`--yes` opens it without asking. Reusable secrets open right away. Without an argument the link is read from stdin, or asked for without showing what you paste, which keeps it out of your shell history and the scrollback too.
When a secret holds several files, `open` lists them with their sizes and asks which to save. Enter saves them all; numbers, ranges and names or patterns pick some, as in `2`, `1 3`, `1-2` or `*.jpg`, and a list of more than 30 files shows the first 30, while numbers and patterns reach them all. Of a one-time secret, the files you don't save are gone with it, and it says so before it asks. A secret over 1 MiB is downloaded after the question, which the server allows for 15 minutes after it is opened, so for one of those it also says the time by which the files have to be saved. Only the files you pick count when names are checked against the directory. `--stdout` asks for the one file to write. With `--yes` or `--json`, or where there is no terminal, nothing is asked: every file is saved, and `--stdout` needs a secret of a single file.
-`-c`/`--copy` puts text on the clipboard instead of the terminal, so it doesn't stay in the scrollback. The final line break is left off, so pasting a password doesn't also press Enter. 45 seconds later the clipboard is cleared, unless you copied something else by then. Before anything is opened, `--copy` checks that there is a clipboard tool (`pbcopy`, `wl-copy`, `xclip`, `xsel` or `clip.exe`) and that the secret is text; should copying still fail, the text is printed after all, so a one-time secret isn't lost.
+`-c`/`--to-clipboard` puts text on the clipboard instead of the terminal, so it doesn't stay in the scrollback. The final line break is left off, so pasting a password doesn't also press Enter. 45 seconds later the clipboard is cleared, unless you copied something else by then. Before anything is opened, `--to-clipboard` checks that there is a clipboard tool (`pbcopy`, `wl-copy`, `xclip`, `xsel` or `clip.exe`) and that the secret is text; should copying still fail, the text is printed after all, so a one-time secret isn't lost.
**Handing a link over with a code.** Instead of copying a link to another device, `send` hands it over with a short code like `7-acid-rocket`. On the other device, type the code at the server's `/c` page (`secretli.app/c`) or run `secretli receive 7-acid-rocket`; `secretli share --code` makes a secret and hands it over in one go. The link travels encrypted, and only after the other device has proved it typed the same code; the words never leave the two devices. A code works once and for ten minutes, and a wrong code ends the transfer on both sides. Given an owner link, `send` hands over only the link to hand out. It works both ways with the web app's "Send with a code".
-`receive` opens what it receives like `open` does, with the same `--out`, `--stdout`, `--force`, `--yes`, `--copy` and password options, or prints the link with `--link` (with `--copy`, it copies the link). If you decline to open a one-time secret, it prints the link instead, since the code is used up by then. Typing is forgiving: `7 acid rocket`, `7-ACID-ROCKET` and `7-aci-roc` all work. Without an argument the code is asked for, and what you type isn't shown; a misspelt word is caught before the code is used.
+`receive` opens what it receives like `open` does, with the same `--out`, `--stdout`, `--force`, `--yes`, `--to-clipboard` and password options, or prints the link with `--link` (with `--to-clipboard`, it copies the link). If you decline to open a one-time secret, it prints the link instead, since the code is used up by then. Typing is forgiving: `7 acid rocket`, `7-ACID-ROCKET` and `7-aci-roc` all work. Without an argument the code is asked for, and what you type isn't shown; a misspelt word is caught before the code is used.
**Checking and deleting.** `status` describes a secret from its link without opening it: text or files, one-time or reusable, password or not, when it was sent and when it expires, and whether it has been opened. Once a secret is gone, opened, deleted or expired, the server keeps nothing about it, so all `status` can say then is that it is gone, to the owner as to a recipient, as it does for a link to nothing. The exit code is 4 then, and with `--json` the state is `live` or `gone`. `delete` takes the owner link and asks before it deletes, unless you pass `--yes`.
diff --git a/internal/cli/clipboard.go b/internal/cli/clipboard.go
index 8c022a9..182ccb4 100644
--- a/internal/cli/clipboard.go
+++ b/internal/cli/clipboard.go
@@ -22,7 +22,7 @@ const clipboardClearAfter = 45 * time.Second
// clipboardTool is the desktop's clipboard.
type clipboardTool interface {
// Available fails when there is no clipboard to copy to, so that
- // --copy is refused before anything is opened.
+ // --to-clipboard is refused before anything is opened.
Available() error
Copy(text string) error
Paste() (string, error)
diff --git a/internal/cli/clipboard_test.go b/internal/cli/clipboard_test.go
index c3adee0..a8da2a6 100644
--- a/internal/cli/clipboard_test.go
+++ b/internal/cli/clipboard_test.go
@@ -94,7 +94,7 @@ func TestOpenCopiesTheSecretInsteadOfPrintingIt(t *testing.T) {
cb := fakeClipboard(t)
link, _ := shareText(t, "--server="+srv.URL, "hunter2\n")
- stdout, stderr, code := runCLI(t, "", "open", link, "--copy", "--yes")
+ stdout, stderr, code := runCLI(t, "", "open", link, "--to-clipboard", "--yes")
if code != 0 || stdout != "" {
t.Fatalf("exit %d, stdout %q, stderr %q", code, stdout, stderr)
}
@@ -112,12 +112,12 @@ func TestOpenCopiesTheSecretInsteadOfPrintingIt(t *testing.T) {
}
}
-// The link carries the key, so share --copy has it cleared like open --copy.
+// The link carries the key, so share --to-clipboard has it cleared like open --to-clipboard.
func TestShareCopiesTheLinkAndClearsItLater(t *testing.T) {
srv := fakeServer(t)
cb := fakeClipboard(t)
- stdout, stderr, code := runCLI(t, "the launch code", "share", "--server="+srv.URL, "--copy")
+ stdout, stderr, code := runCLI(t, "the launch code", "share", "--server="+srv.URL, "--to-clipboard")
if code != 0 {
t.Fatalf("exit %d, stderr %q", code, stderr)
}
@@ -134,8 +134,8 @@ func TestShareCopiesTheLinkAndClearsItLater(t *testing.T) {
}
}
-// --paste shares the clipboard's text, and with --copy the link takes its
-// place there: what open --copy gives back is what was pasted.
+// --from-clipboard shares the clipboard's text, and with --to-clipboard the link takes its
+// place there: what open --to-clipboard gives back is what was pasted.
func TestSharePastesTheClipboard(t *testing.T) {
srv := fakeServer(t)
server := "--server=" + srv.URL
@@ -143,7 +143,7 @@ func TestSharePastesTheClipboard(t *testing.T) {
// The paste tool's own line break is not part of the secret.
cb.text, cb.pasteSuffix = "hunter2", "\r\n"
- stdout, stderr, code := runCLI(t, "ignored", "share", server, "--paste", "--copy")
+ stdout, stderr, code := runCLI(t, "ignored", "share", server, "--from-clipboard", "--to-clipboard")
if code != 0 {
t.Fatalf("exit %d, stderr %q", code, stderr)
}
@@ -158,7 +158,7 @@ func TestSharePastesTheClipboard(t *testing.T) {
// With --name, the clipboard is shared as a file.
cb.text = "A=1\nB=2\n"
- link, _ = shareText(t, server, "", "--paste", "--name", ".env")
+ link, _ = shareText(t, server, "", "--from-clipboard", "--name", ".env")
dir := t.TempDir()
if _, stderr, code := runCLI(t, "", "open", link, "--yes", "--out", dir); code != 0 {
t.Fatalf("open file: exit %d, stderr %q", code, stderr)
@@ -179,18 +179,18 @@ func TestPasteIsRefusedBeforeAnythingIsUploaded(t *testing.T) {
cb.text = "x"
for _, args := range [][]string{{"-t", "y"}, {file}, {"-"}} {
- if _, stderr, code := runCLI(t, "", append([]string{"share", server, "--paste"}, args...)...); code != ExitError || !strings.Contains(stderr, "--paste shares the clipboard; leave out --text and files") {
+ if _, stderr, code := runCLI(t, "", append([]string{"share", server, "--from-clipboard"}, args...)...); code != ExitError || !strings.Contains(stderr, "--from-clipboard shares the clipboard; leave out --text and files") {
t.Errorf("%v: exit %d, stderr %q", args, code, stderr)
}
}
cb.text = "\n"
- if _, stderr, code := runCLI(t, "", "share", server, "--paste"); code != ExitError || !strings.Contains(stderr, "--paste: the clipboard holds no text") {
+ if _, stderr, code := runCLI(t, "", "share", server, "--from-clipboard"); code != ExitError || !strings.Contains(stderr, "--from-clipboard: the clipboard holds no text") {
t.Errorf("empty clipboard: exit %d, stderr %q", code, stderr)
}
clipboard = noClipboard{}
- if _, stderr, code := runCLI(t, "", "share", server, "--paste"); code != ExitError || !strings.Contains(stderr, "--paste: no clipboard tool found") {
+ if _, stderr, code := runCLI(t, "", "share", server, "--from-clipboard"); code != ExitError || !strings.Contains(stderr, "--from-clipboard: no clipboard tool found") {
t.Errorf("no clipboard: exit %d, stderr %q", code, stderr)
}
}
@@ -205,11 +205,11 @@ func TestCopyIsRefusedBeforeAnythingIsUsedUp(t *testing.T) {
args []string
want string
}{
- {[]string{"--stdout"}, "--stdout writes a file and --copy copies text"},
- {[]string{"--json"}, "--json prints the secret; leave out --copy"},
+ {[]string{"--stdout"}, "--stdout writes a file and --to-clipboard copies text"},
+ {[]string{"--json"}, "--json prints the secret; leave out --to-clipboard"},
} {
// With --json, the error is JSON on stdout.
- stdout, stderr, code := runCLI(t, "", append([]string{"open", link, "--copy", "--yes"}, tc.args...)...)
+ stdout, stderr, code := runCLI(t, "", append([]string{"open", link, "--to-clipboard", "--yes"}, tc.args...)...)
if code != ExitError || !strings.Contains(stdout+stderr, tc.want) {
t.Errorf("%v: exit %d, stdout %q, stderr %q", tc.args, code, stdout, stderr)
}
@@ -217,7 +217,7 @@ func TestCopyIsRefusedBeforeAnythingIsUsedUp(t *testing.T) {
// No clipboard tool: refused before the link is even read.
clipboard = noClipboard{}
- if _, stderr, code := runCLI(t, "", "open", link, "--copy", "--yes"); code != ExitError || !strings.Contains(stderr, "--copy: no clipboard tool found") {
+ if _, stderr, code := runCLI(t, "", "open", link, "--to-clipboard", "--yes"); code != ExitError || !strings.Contains(stderr, "--to-clipboard: no clipboard tool found") {
t.Errorf("no clipboard: exit %d, stderr %q", code, stderr)
}
clipboard = cb
@@ -229,7 +229,7 @@ func TestCopyIsRefusedBeforeAnythingIsUsedUp(t *testing.T) {
t.Fatal(err)
}
fileLink, _ := shareText(t, server, "", notes)
- if _, stderr, code := runCLI(t, "", "open", fileLink, "--copy", "--yes"); code != ExitError || !strings.Contains(stderr, "--copy is for text, and this secret holds files") {
+ if _, stderr, code := runCLI(t, "", "open", fileLink, "--to-clipboard", "--yes"); code != ExitError || !strings.Contains(stderr, "--to-clipboard is for text, and this secret holds files") {
t.Errorf("files: exit %d, stderr %q", code, stderr)
}
@@ -249,7 +249,7 @@ func TestACopyThatFailsPrintsTheSecretAfterAll(t *testing.T) {
link, _ := shareText(t, "--server="+srv.URL, "hunter2\n")
// The one-time secret is used up by then, so this is the only copy.
- stdout, stderr, code := runCLI(t, "", "open", link, "--copy", "--yes")
+ stdout, stderr, code := runCLI(t, "", "open", link, "--to-clipboard", "--yes")
if code != 0 || stdout != "hunter2\n" || !strings.Contains(stderr, "Couldn't copy to the clipboard (xclip: exit status 1), so here it is:") {
t.Errorf("exit %d, stdout %q, stderr %q", code, stdout, stderr)
}
@@ -272,7 +272,7 @@ func TestReceiveCopies(t *testing.T) {
}
link, _ := shareText(t, server, "handed over\n")
- if stdout, stderr, code := receive(link, "--copy", "--yes"); code != 0 || stdout != "" {
+ if stdout, stderr, code := receive(link, "--to-clipboard", "--yes"); code != 0 || stdout != "" {
t.Errorf("text: exit %d, stdout %q, stderr %q", code, stdout, stderr)
}
if text, _ := cb.state(); text != "handed over" {
@@ -281,7 +281,7 @@ func TestReceiveCopies(t *testing.T) {
// With --link, the link is what goes on the clipboard.
link, _ = shareText(t, server, "a link\n")
- if stdout, stderr, code := receive(link, "--copy", "--link"); code != 0 || stdout != "" || !strings.Contains(stderr, "Copied the link") {
+ if stdout, stderr, code := receive(link, "--to-clipboard", "--link"); code != 0 || stdout != "" || !strings.Contains(stderr, "Copied the link") {
t.Errorf("link: exit %d, stdout %q, stderr %q", code, stdout, stderr)
}
if text, _ := cb.state(); text != link {
@@ -296,8 +296,8 @@ func TestReceiveCopies(t *testing.T) {
t.Fatal(err)
}
fileLink, _ := shareText(t, server, "", notes)
- stdout, stderr, code := receive(fileLink, "--copy", "--yes")
- if code != ExitError || strings.TrimSpace(stdout) != fileLink || !strings.Contains(stderr, "Not opened: --copy is for text") || !strings.Contains(stderr, "Here is the link, which still works") {
+ stdout, stderr, code := receive(fileLink, "--to-clipboard", "--yes")
+ if code != ExitError || strings.TrimSpace(stdout) != fileLink || !strings.Contains(stderr, "Not opened: --to-clipboard is for text") || !strings.Contains(stderr, "Here is the link, which still works") {
t.Errorf("files: exit %d, stdout %q, stderr %q", code, stdout, stderr)
}
if _, stderr, code := runCLI(t, "", "open", fileLink, "--yes", "--out", filepath.Join(dir, "received")); code != 0 {
@@ -372,7 +372,7 @@ func TestTabCompletion(t *testing.T) {
}
}
- // The command behind --copy's clearing stays out of sight.
+ // The command behind --to-clipboard's clearing stays out of sight.
if stdout, _, _ := runCLI(t, "", "--help"); strings.Contains(stdout, "clear-clipboard") {
t.Errorf("help lists clear-clipboard: %q", stdout)
}
diff --git a/internal/cli/open.go b/internal/cli/open.go
index 7f97724..a8f9c65 100644
--- a/internal/cli/open.go
+++ b/internal/cli/open.go
@@ -25,15 +25,15 @@ type openOptions struct {
password bool
passwordFile string
yes bool
- copy bool
+ toClipboard bool
}
// errNotOpened is a one-time secret the person chose not to open yet.
var errNotOpened = errors.New("not opened")
-// errCopyIsForText is --copy on a secret that holds files, found out
+// errCopyIsForText is --to-clipboard on a secret that holds files, found out
// before it is opened.
-var errCopyIsForText = errors.New("--copy is for text, and this secret holds files; leave out --copy to save them")
+var errCopyIsForText = errors.New("--to-clipboard is for text, and this secret holds files; leave out --to-clipboard to save them")
func newOpenCmd(e *env) *cobra.Command {
var o openOptions
@@ -44,7 +44,7 @@ func newOpenCmd(e *env) *cobra.Command {
saved to the current directory, or to --out, and never overwrite anything
unless --force is given. At a terminal, control characters in the text, which
could steer the terminal, are shown as a replacement character, and you are
-told; --copy, or stdout to a file or pipe, gives the exact text.
+told; --to-clipboard, or stdout to a file or pipe, gives the exact text.
Of a secret with several files, at a terminal, the files are listed and you
are asked which to save: Enter saves them all, and numbers, ranges and
@@ -53,8 +53,8 @@ the one to write. With --yes or --json, or where there is no terminal to
ask on, nothing is asked: every file is saved, and --stdout needs a secret
of a single file.
---copy puts text on the clipboard instead, without its final line break,
-so it never shows in the terminal or its scrollback. The clipboard is
+--to-clipboard puts text on the clipboard instead, without its final line
+break, so it never shows in the terminal or its scrollback. The clipboard is
cleared 45 seconds later, unless something else was copied by then.
Opening a one-time secret is what uses it up, so the link is described first
@@ -66,7 +66,7 @@ scrollback.`,
Example: ` secretli open 'https://secretli.app/s#…'
secretli open 'https://secretli.app/s#…' --out ./received
secretli open 'https://secretli.app/s#…' --stdout > backup.tgz
- secretli open 'https://secretli.app/s#…' --copy
+ secretli open 'https://secretli.app/s#…' --to-clipboard
pbpaste | secretli open`,
Args: cobra.MaximumNArgs(1),
ValidArgsFunction: cobra.NoFileCompletions,
@@ -92,24 +92,24 @@ func addOpenFlags(cmd *cobra.Command, o *openOptions) {
f.BoolVarP(&o.password, "password", "p", false, "the secret has a password (asked for, or SECRETLI_PASSWORD)")
f.StringVar(&o.passwordFile, "password-file", "", "read the password from the first line of this file")
f.BoolVarP(&o.yes, "yes", "y", false, "open a one-time secret without asking; needed when not at a terminal")
- f.BoolVarP(&o.copy, "copy", "c", false, "copy text to the clipboard instead of printing it; cleared after 45 seconds")
+ f.BoolVarP(&o.toClipboard, "to-clipboard", "c", false, "copy text to the clipboard instead of printing it; cleared after 45 seconds")
_ = cmd.MarkFlagDirname("out")
}
-// checkCopy refuses --copy where it cannot work. It runs before the link or
-// the code is taken, so that nothing is used up for a refusal.
+// checkCopy refuses --to-clipboard where it cannot work. It runs before the
+// link or the code is taken, so that nothing is used up for a refusal.
func (e *env) checkCopy(o openOptions) error {
- if !o.copy {
+ if !o.toClipboard {
return nil
}
switch {
case o.toStdout:
- return errors.New("--stdout writes a file and --copy copies text; use one of them")
+ return errors.New("--stdout writes a file and --to-clipboard copies text; use one of them")
case e.json:
- return errors.New("--json prints the secret; leave out --copy")
+ return errors.New("--json prints the secret; leave out --to-clipboard")
}
if err := clipboard.Available(); err != nil {
- return fmt.Errorf("--copy: %w", err)
+ return fmt.Errorf("--to-clipboard: %w", err)
}
return nil
}
@@ -134,7 +134,7 @@ func (e *env) openLink(ctx context.Context, o openOptions, link share.Link) erro
return err
}
e.say("%s\n", describeInfo(info, link.IsOwner(), now))
- if o.copy && info.Kind != share.KindText {
+ if o.toClipboard && info.Kind != share.KindText {
return errCopyIsForText
}
if !info.Reusable && !o.yes {
@@ -158,7 +158,7 @@ func (e *env) openLink(ctx context.Context, o openOptions, link share.Link) erro
opened, err := share.Open(ctx, c, link, password, sink, bar.update)
bar.finish()
if err == nil {
- return e.printOpened(opened, sink, o.copy)
+ return e.printOpened(opened, sink, o.toClipboard)
}
// A mistyped password doesn't use the secret up, but the server
// counts it, and at the last one it takes deletes the secret. Ask
@@ -450,7 +450,7 @@ func (e *env) writeText(text []byte) error {
}
if changed {
// Even with --quiet: what was printed is not quite the secret.
- _, _ = fmt.Fprint(e.stderr, "The secret holds control characters, shown as \uFFFD; --copy, or stdout to a file or pipe, gives the exact text.\n")
+ _, _ = fmt.Fprint(e.stderr, "The secret holds control characters, shown as \uFFFD; --to-clipboard, or stdout to a file or pipe, gives the exact text.\n")
}
return nil
}
diff --git a/internal/cli/receive.go b/internal/cli/receive.go
index bf51bf1..01d4dfc 100644
--- a/internal/cli/receive.go
+++ b/internal/cli/receive.go
@@ -29,8 +29,8 @@ func newReceiveCmd(e *env) *cobra.Command {
Long: `Receives a link that another device hands over with a short code, from
secretli send or from "Send with a code" in the web app, and opens it like
secretli open: text to stdout, files to the current directory or --out.
---link prints the link instead of opening it. --copy puts the text, or with
---link the link, on the clipboard instead, as with open.
+--link prints the link instead of opening it. --to-clipboard puts the text,
+or with --link the link, on the clipboard instead, as with open.
A one-time secret is described and you are asked before it is opened, as
with open; --yes opens it without asking. Answering no prints the link,
@@ -85,7 +85,7 @@ func (e *env) receive(ctx context.Context, o receiveOptions, args []string) erro
return fmt.Errorf("the code delivered a link for another server, %s; it was not opened", link.Origin)
}
if o.linkOnly {
- if o.copy {
+ if o.toClipboard {
return e.copySecret(link.String(), "the link")
}
return e.printLink(link)
diff --git a/internal/cli/share.go b/internal/cli/share.go
index 7e2b48d..9e9df59 100644
--- a/internal/cli/share.go
+++ b/internal/cli/share.go
@@ -19,16 +19,16 @@ import (
)
type shareOptions struct {
- text string
- name string
- expires string
- passwordFile string
- reusable bool
- password bool
- qr bool
- copyLink bool
- paste bool
- code bool
+ text string
+ name string
+ expires string
+ passwordFile string
+ reusable bool
+ password bool
+ qr bool
+ toClipboard bool
+ fromClipboard bool
+ code bool
}
func newShareCmd(e *env) *cobra.Command {
@@ -41,16 +41,16 @@ to hand out, and the owner link, which can delete the secret and, for a
reusable one, tell whether it has been opened.
Files are given as arguments. Text comes from stdin, from --text, from the
-clipboard with --paste, or, at a terminal, from a prompt, which keeps it out
-of your shell history. "-" shares stdin as a file named by --name, and --name
-with --paste shares the clipboard as a file.
+clipboard with --from-clipboard, or, at a terminal, from a prompt, which
+keeps it out of your shell history. "-" shares stdin as a file named by
+--name, and --name with --from-clipboard shares the clipboard as a file.
Links open once unless --reusable is set, and expire after a day unless
--expires says otherwise. --code hands the link to another device with a
short code instead of printing it, as secretli send does.`,
Example: ` secretli share type or paste, then Ctrl-D
pbpaste | secretli share text from a pipe
- secretli share --paste -c the clipboard's text in, the link out
+ secretli share --from-clipboard -c the clipboard's text in, the link out
secretli share -t "hunter2" text as an argument (lands in shell history)
secretli share deploy.key notes.pdf files
pg_dump db | gzip | secretli share --name db.sql.gz
@@ -70,8 +70,8 @@ short code instead of printing it, as secretli send does.`,
f.BoolVarP(&o.password, "password", "p", false, "protect the secret with a password (asked for, or SECRETLI_PASSWORD)")
f.StringVar(&o.passwordFile, "password-file", "", "read the password from the first line of this file")
f.BoolVar(&o.qr, "qr", false, "show the link as a QR code too")
- f.BoolVarP(&o.copyLink, "copy", "c", false, "copy the link to the clipboard; cleared after 45 seconds")
- f.BoolVar(&o.paste, "paste", false, "share the clipboard's text, without its final line break")
+ f.BoolVarP(&o.toClipboard, "to-clipboard", "c", false, "copy the link to the clipboard; cleared after 45 seconds")
+ f.BoolVar(&o.fromClipboard, "from-clipboard", false, "share the clipboard's text, without its final line break")
f.BoolVar(&o.code, "code", false, "hand the link to another device with a short code instead of printing it")
return cmd
}
@@ -80,8 +80,8 @@ func (e *env) share(ctx context.Context, o shareOptions, args []string) error {
if !share.ValidExpiration(o.expires) {
return fmt.Errorf("--expires must be one of %s", strings.Join(share.Expirations, ", "))
}
- if o.code && (o.qr || o.copyLink) {
- return errors.New("--code hands the link over itself; leave out --qr and --copy")
+ if o.code && (o.qr || o.toClipboard) {
+ return errors.New("--code hands the link over itself; leave out --qr and --to-clipboard")
}
// Before anything is read or uploaded: the link has to be one that
// opens, which rules out http to another machine.
@@ -89,8 +89,8 @@ func (e *env) share(ctx context.Context, o shareOptions, args []string) error {
if err != nil {
return err
}
- if o.paste && (o.text != "" || len(args) > 0) {
- return errors.New("--paste shares the clipboard; leave out --text and files")
+ if o.fromClipboard && (o.text != "" || len(args) > 0) {
+ return errors.New("--from-clipboard shares the clipboard; leave out --text and files")
}
params := share.Params{Expiration: o.expires, Reusable: o.reusable}
@@ -127,7 +127,7 @@ func (e *env) share(ctx context.Context, o shareOptions, args []string) error {
switch {
case o.text != "":
params.Text = []byte(o.text)
- case o.paste:
+ case o.fromClipboard:
data, err := pasteSecret()
if err != nil {
return err
@@ -212,17 +212,17 @@ func (e *env) readStdin(ctx context.Context) ([]byte, error) {
return data, nil
}
-// pasteSecret reads the clipboard for --paste. It drops one final line
-// break, which a paste tool may add of its own and open --copy leaves off,
-// so that what --paste shares, open --copy gives back.
+// pasteSecret reads the clipboard for --from-clipboard. It drops one final line
+// break, which a paste tool may add of its own and open --to-clipboard leaves off,
+// so that what --from-clipboard shares, open --to-clipboard gives back.
func pasteSecret() ([]byte, error) {
text, err := clipboard.Paste()
if err != nil {
- return nil, fmt.Errorf("--paste: %w", err)
+ return nil, fmt.Errorf("--from-clipboard: %w", err)
}
text = withoutFinalLineBreak(text)
if text == "" {
- return nil, errors.New("--paste: the clipboard holds no text")
+ return nil, errors.New("--from-clipboard: the clipboard holds no text")
}
return []byte(text), nil
}
@@ -265,7 +265,7 @@ func (e *env) printShared(r *share.Result, o shareOptions) error {
e.note("Couldn't draw the QR code: %v\n", err)
}
}
- if o.copyLink {
+ if o.toClipboard {
// The link is printed below anyway, so a failure needs no stand-in.
if err := e.copyAndClear(link, "the link"); err != nil {
e.note("Couldn't copy to the clipboard: %v\n", err)
diff --git a/internal/cli/transfer_test.go b/internal/cli/transfer_test.go
index f743191..6c3676c 100644
--- a/internal/cli/transfer_test.go
+++ b/internal/cli/transfer_test.go
@@ -165,7 +165,7 @@ func TestReceiveRefusesBadCodes(t *testing.T) {
{[]string{"receive", "7-acid-rocket", server, "--yes"}, ExitGone, "no transfer with that number"},
{[]string{"receive", "acid-rocket", server, "--yes"}, ExitError, "codes look like 7-acid-rocket"},
{[]string{"receive", "7-acid-rokcet", server, "--yes"}, ExitError, `"rokcet" isn't a code word`},
- {[]string{"share", "-t", "x", "--code", "--qr", server}, ExitError, "leave out --qr and --copy"},
+ {[]string{"share", "-t", "x", "--code", "--qr", server}, ExitError, "leave out --qr and --to-clipboard"},
} {
_, stderr, code := runCLI(t, "", c.args...)
if code != c.exit || !strings.Contains(stderr, c.says) {
diff --git a/internal/cli/untrusted.go b/internal/cli/untrusted.go
index b2d1f16..4b2951a 100644
--- a/internal/cli/untrusted.go
+++ b/internal/cli/untrusted.go
@@ -12,7 +12,7 @@ import (
// what was printed, retitle the window, show a link that leads elsewhere,
// or set the clipboard. Format characters such as U+202E reverse text on
// display: invoice, U+202E, txt.exe reads as invoiceexe.txt. Pipes, files,
-// --copy and --json get the text as it is.
+// --to-clipboard and --json get the text as it is.
// printable is a file's name as the terminal may show it: control and
// format characters, and bytes that aren't UTF-8, become '?'.