-
Notifications
You must be signed in to change notification settings - Fork 59
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
feat(#58): add copy to clipboard flag --copy
#97
base: main
Are you sure you want to change the base?
feat(#58): add copy to clipboard flag --copy
#97
Conversation
@AlejandroSuero Not working, I cloned your fork, checked out your branch and compiled. ❯ make test
go test ./...
? github.com/charmbracelet/freeze/font [no test files]
? github.com/charmbracelet/freeze/input [no test files]
? github.com/charmbracelet/freeze/svg [no test files]
? github.com/charmbracelet/freeze/test/input [no test files]
--- FAIL: TestFreezeCopy (0.04s)
freeze_test.go:81: clipboard is empty
FAIL
FAIL github.com/charmbracelet/freeze 2.748s
FAIL
make: *** [test] Error 1
|
@Moulick I am using the same version of MacOS and it builds correctly with add-copy-to-clipboard-branch-demo.mp4As for the test part, I committed a fix (eba42f9), apparently it was reading from the clipboard but not writing it, for example: If I have an image on the clipboard it will pass the test but it will fail otherwise. |
@AlejandroSuero now the test works, and the image generated by the make test appears in my clipboard. But running |
After
With these, are you referring to the fact that it writes the output image as well as copying it to the clipboard? When running |
@AlejandroSuero not sure if there is something wrong with my machine but for me |
freezezip-just-powered-up-machine.mp4@Moulick this is how it works for me just powering up the machine and having the clipboard empty. |
With the changes in c57172d, It still passes the tests and works the same way manually for me. |
Hey @AlejandroSuero, instead of introducing a new flag I wonder if we should simply allow |
No opinions, but you could also introduce the option to print to stdout so you could |
In that case I would rather simply detect if stdout is a tty and send to stdout if it's not a tty.
|
@maaslalani the problem I contemplated when I thought about it in the first place was that if for example you want to write an output name like But I would like to hear your thoughts about that scenario. |
@meowgorithm as for the |
|
With [gclip](https://github.com/golang-design/clipboard) when not copying a png image `gclip -copy -f freeze.svg` it will copy it as text, otherwise as an image
As @maaslalani suggested, I made the changes so the user can With these changes (9a169d5, 01d684a), the comment #97 (comment) is worked around so it will always use Test Results> go test -v ./...
? github.com/charmbracelet/freeze/font [no test files]
? github.com/charmbracelet/freeze/input [no test files]
? github.com/charmbracelet/freeze/test/input [no test files]
? github.com/charmbracelet/freeze/svg [no test files]
=== RUN TestConfig
--- PASS: TestConfig (0.00s)
=== RUN TestCut
--- PASS: TestCut (0.00s)
=== RUN TestFreeze
--- PASS: TestFreeze (0.27s)
=== RUN TestFreezeOutput
--- PASS: TestFreezeOutput (0.04s)
=== RUN TestFreezeCopy
--- PASS: TestFreezeCopy (0.50s)
=== RUN TestFreezeHelp
--- PASS: TestFreezeHelp (0.01s)
=== RUN TestFreezeErrorFileMissing
--- PASS: TestFreezeErrorFileMissing (0.01s)
=== RUN TestFreezeConfigurations
=== RUN TestFreezeConfigurations/artichoke-base
=== RUN TestFreezeConfigurations/artichoke-full
=== RUN TestFreezeConfigurations/eza
=== RUN TestFreezeConfigurations/execute
=== RUN TestFreezeConfigurations/bubbletea
=== RUN TestFreezeConfigurations/bubbletea-copy
=== RUN TestFreezeConfigurations/layout
=== RUN TestFreezeConfigurations/haskell
=== RUN TestFreezeConfigurations/dracula
=== RUN TestFreezeConfigurations/border-radius
=== RUN TestFreezeConfigurations/window
=== RUN TestFreezeConfigurations/border-width
=== RUN TestFreezeConfigurations/padding
=== RUN TestFreezeConfigurations/margin
=== RUN TestFreezeConfigurations/shadow
=== RUN TestFreezeConfigurations/dimensions
=== RUN TestFreezeConfigurations/dimensions-margin
=== RUN TestFreezeConfigurations/dimensions-margin-line-numbers
=== RUN TestFreezeConfigurations/dimensions-padding
=== RUN TestFreezeConfigurations/dimensions-config
=== RUN TestFreezeConfigurations/overflow
=== RUN TestFreezeConfigurations/lines
=== RUN TestFreezeConfigurations/font-size-28
=== RUN TestFreezeConfigurations/font-size-14
=== RUN TestFreezeConfigurations/line-height-2
=== RUN TestFreezeConfigurations/overflow-line-numbers
=== RUN TestFreezeConfigurations/helix
=== RUN TestFreezeConfigurations/glow
=== RUN TestFreezeConfigurations/tab
--- PASS: TestFreezeConfigurations (0.77s)
--- PASS: TestFreezeConfigurations/artichoke-base (0.02s)
--- PASS: TestFreezeConfigurations/artichoke-full (0.02s)
--- PASS: TestFreezeConfigurations/eza (0.02s)
--- PASS: TestFreezeConfigurations/execute (0.03s)
--- PASS: TestFreezeConfigurations/bubbletea (0.03s)
--- PASS: TestFreezeConfigurations/bubbletea-copy (0.03s)
--- PASS: TestFreezeConfigurations/layout (0.03s)
--- PASS: TestFreezeConfigurations/haskell (0.03s)
--- PASS: TestFreezeConfigurations/dracula (0.03s)
--- PASS: TestFreezeConfigurations/border-radius (0.03s)
--- PASS: TestFreezeConfigurations/window (0.03s)
--- PASS: TestFreezeConfigurations/border-width (0.03s)
--- PASS: TestFreezeConfigurations/padding (0.03s)
--- PASS: TestFreezeConfigurations/margin (0.03s)
--- PASS: TestFreezeConfigurations/shadow (0.03s)
--- PASS: TestFreezeConfigurations/dimensions (0.03s)
--- PASS: TestFreezeConfigurations/dimensions-margin (0.03s)
--- PASS: TestFreezeConfigurations/dimensions-margin-line-numbers (0.03s)
--- PASS: TestFreezeConfigurations/dimensions-padding (0.03s)
--- PASS: TestFreezeConfigurations/dimensions-config (0.03s)
--- PASS: TestFreezeConfigurations/overflow (0.03s)
--- PASS: TestFreezeConfigurations/lines (0.03s)
--- PASS: TestFreezeConfigurations/font-size-28 (0.03s)
--- PASS: TestFreezeConfigurations/font-size-14 (0.03s)
--- PASS: TestFreezeConfigurations/line-height-2 (0.03s)
--- PASS: TestFreezeConfigurations/overflow-line-numbers (0.03s)
--- PASS: TestFreezeConfigurations/helix (0.03s)
--- PASS: TestFreezeConfigurations/glow (0.02s)
--- PASS: TestFreezeConfigurations/tab (0.02s)
PASS
ok github.com/charmbracelet/freeze 3.405s |
Changes made
With this addition the user can choose in interactive mode, or with the flag
--copy
, to copy the created image to their system's clipboard. This was achieved with the cross-platform clipboard package by golang-design.Tests
make test
:./freeze --config user --lines 23,30 config.go --copy
to get this image:Closes #58.