Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change CLI messages to use CROC_SECRET #759

Closed
wants to merge 3 commits into from
Closed

Conversation

01-1
Copy link
Contributor

@01-1 01-1 commented Jul 22, 2024

This pull request changes the cli messages to use CROC_SECRET.
Previously, the error message used export CROC_SECRET, which is unnecessary as you can just run CROC_SECRET=**** croc in one line.
Also, the messages for the sender used the classic command:

On the other computer run

croc ****

This made it incompatible with UNIX unless classic mode was activated.

The new command is

CROC_SECRET=**** croc

I also fixed a typo in the cli error messages.

@01-1
Copy link
Contributor Author

01-1 commented Jul 22, 2024

Not sure if CROC_SECRET works on all platforms though (windows?)
If not, this should be edited to show commands for both UNIX and non-UNIX.

src/croc/croc.go Outdated
@@ -646,7 +646,7 @@ func (c *Client) Send(filesInfo []FileInfo, emptyFoldersToTransfer []FileInfo, t
if c.Options.RelayPassword != models.DEFAULT_PASSPHRASE {
flags.WriteString("--pass " + c.Options.RelayPassword + " ")
}
fmt.Fprintf(os.Stderr, "Code is: %[1]s\nOn the other computer run\n\ncroc %[2]s%[1]s\n", c.Options.SharedSecret, flags.String())
fmt.Fprintf(os.Stderr, "Code is: %[1]s\nOn the other computer run\n\nCROC_SECRET=%[1]s croc %[2]s\n", c.Options.SharedSecret, flags.String())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessary on Windows. Can you change it to only print this on Unix systems (you can use runtime.GOOS == "windows")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The receiver system may not be the same as the sender. I changed this to print both commands.

@schollz
Copy link
Owner

schollz commented Jul 25, 2024

CROC_SECRET is not needed on Windows, so please keep the regular print statements for Windows systems (if os.Runtime=="windows") and have your new print statement for non-windows

@schollz
Copy link
Owner

schollz commented Jul 27, 2024

@01-1 does the suggested change make sense?

@01-1
Copy link
Contributor Author

01-1 commented Jul 27, 2024

No, it doesn't - as per my comment, the receiver system may not be the same as the sender. For example, a windows system could send a file to a unix system, and vice versa.

@schollz
Copy link
Owner

schollz commented Jul 27, 2024

I think its best to revert line 649 back to original. The receiver should interact with the messages

@01-1
Copy link
Contributor Author

01-1 commented Jul 27, 2024

It doesn't make sense to tell the user to run a command that will not work by default.
Maybe just remove the command altogether

@schollz
Copy link
Owner

schollz commented Jul 27, 2024

I think we can all agree that no one agrees on user interaction.

to me, the interaction makes sense because you type in croc PASSPHRASE and you get a explainer of all your options:

On UNIX systems, to receive with croc you either need
to set a code phrase using your environmental variables:

  export CROC_SECRET="****"
  croc

Or you can specify the code phrase when you run croc without
declaring the secret on the command line:

  croc
  Enter receive code: ****

Or you can go back to the classic croc behavior by enabling classic mode:

  croc --classic

versus having to have that information in the sender's purview also.

@01-1
Copy link
Contributor Author

01-1 commented Jul 27, 2024

OK. It is much easier to be able to copy-paste the command though. Maybe add an option to print the unix command?

@schollz
Copy link
Owner

schollz commented Jul 28, 2024

I mean, its pretty easy just to type croc on your receiver, press enter, and copy paste the password? if you are on a single computer, thats really the easiset

@nhtzr
Copy link
Contributor

nhtzr commented Aug 13, 2024

Hi. I arrived here because I wanted to propose a similar change. I believe a workflow that easily and quickly lets you do the right thing is valuable as it reduces the amount of frustation of anyone involved.

However I think the proposed message is hard to read, I would prefer something like:

Sending 'a.txt' (2.6 kB)         
Code is: 1106-yoyo-genius-patent

On the other computer run:
(For Windows)
    croc 1106-yoyo-genius-patent
(For Linux/OSX)
    CROC_SECRET="1106-yoyo-genius-patent" croc

Code would be

	fmt.Fprintf(os.Stderr, `Code is: %[1]s

On the other computer run:
(For Windows)
    croc %[2]s%[1]s
(For Linux/OSX)
    CROC_SECRET=%[1]q croc %[2]s
`, c.Options.SharedSecret, flags.String())

@schollz
Copy link
Owner

schollz commented Aug 16, 2024

@nhtzr please submit a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants