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

add useful utility functions for PostPasteResponse #6

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

nain-F49FF806
Copy link
Contributor

Advantages:

  • Simplify output logic a bit
  • More portable (importable by library users)
  • Allows convenient delete_url to be displayed to user

I haven't changed the CLI output in order to keep compatibility.

But as an idea, something like the following could be used for output when TTY detected.

        let paste_url_str = format!("Paste url: {}", res.to_url(api.base()).as_str());
        std::io::stdout().write_all(paste_url_str.as_bytes())?;
        writeln!(std::io::stdout())?;
        let delete_url_str = format!("Delete url: {}", res.to_delete_url(api.base()).as_str());
        std::io::stdout().write_all(delete_url_str.as_bytes())?;
        writeln!(std::io::stdout())?;

Output:

Paste url: https://privatebin.net/?0a37477133f68c6c#48k1bFdRRfkMGxaKVdPEvRryABJ6cSdFk1c6RoPEbjq7
Delete url: https://privatebin.net/?pasteid=0a37477133f68c6c&deletetoken=7325797b0957881829d9f052d0c3d4281e4c6cb8bc50f1509c573669c7eff066

@Mydayyy
Copy link
Owner

Mydayyy commented Apr 3, 2024

Greetings,

I apologize for the late reply.

I like the idea of extracting that kind of functionality into the struct.

I haven't changed the CLI output in order to keep compatibility.
But as an idea, something like the following could be used for output when TTY detected.

This idea is great as well. As you already mentioned currently this would break backward functionality, but in general I like the idea of adapting the output based on whether it is an interactive session or not.

What would be possible is to extend the output for the --json switch, for example add deleteurl and pasteurl as keys there. Makes it easier to access it via scripting without having to assemble it yourself from the other pieces.

I will test and merge it later once I am at my computer. Thank you for the contribution!

Best Regards
Mydayyy

@Mydayyy Mydayyy merged commit 002b911 into Mydayyy:master Apr 3, 2024
1 check passed
@nain-F49FF806
Copy link
Contributor Author

Greeting,

Just wanted to let you know that Share Paste app, which uses uniffi bindings to expose this library in Android, is now live!
You can see how we're using this functionality over here: readme-screenshots.

I also maintain a branch of pbcli with the uniffi bindings here.
Feel free to have a look and add to upstream if it makes sense at some point.

Best regards. :)

@Mydayyy
Copy link
Owner

Mydayyy commented Apr 6, 2024

wow, thats great 😮 I'm honored that you chose PBCLI as your library of choice for the PrivateBin communication, thank you!

If you want you can create a PR to merge the UniFFI branch into here. It will just take me a few days to go over that since I also plan to read some basics about UniFFI

Best Regards
Mydayyy

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.

2 participants