-
Notifications
You must be signed in to change notification settings - Fork 8
Major revision: a CLI as an example, and several improvements in the Tinify package #8
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
Open
GwynethLlewelyn
wants to merge
84
commits into
gwpp:master
Choose a base branch
from
GwynethLlewelyn:gwyn-cli
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… because the API requires it!
This is just syntactic sugar for Go to compile the “local” module as if it were the “real” module.
Not even worth a commit.
… but added some info regarding the CPI example, too.
It’s more efficient
It’s not really used and should probably be abolished.
If error, return is a valid integer with 0. Since we deal with image sizes here, a size of zero is by no means acceptable upstream.
Minor cleaning up bugs required but that’s IT.
… and I forgot all about that
Also: added more debug messaeges
As suggestd by ChatGPT.
… now, there it goes, in spades!
There is still a lot left to fix…
(e.g. for resize with scale, only width OR height can be non-zero, and the missing dimension should be skipped)
Seems to work, according to the tests!
This is just to make it future-proof!
Set in “secret” environment for GiHub Actions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there,
The stand-alone CLI which I had added on PR #7 got a big revamp.
Besides extending the existing package code to deal with the latest innovations by Tinify, such as support for more file types and a new resizing option, I've also managed to add more comments, clean up the JSON being sent, and properly deal with error codes sent by the API endpoint; additionally, I've introduced a few new features, such as extract (and pass back) the current token count (perhaps, at some point, it might even be possible to avoid making API calls if one's token limit has been reached). I cannot guarantee 100% compatibility with past versions, but it should be close enough.
I gave up on my clumsy attempts to build my own CLI framework, I was wasting too much time and getting nowhere. So, I went back to good, old, faithful
urfave/cli, and redid everything from scratch, using version 3 of that package. With a bit of hand-holding by some knowledgeable developers, who pointed out glaring mistakes in my code (thus explaining why "nothing worked" in my previous attempt), I managed to get it to work fine (extra bonus: auto-completion works!).Since I was mostly going to use this tool for batch processing, I also felt the need to use a more robust logging system, as opposed to just sending
fmt.Fprintf(os.Stderr, "..."); after checking a few benchmarks, I've decided to usezerologin itsConsoleWritermode — that could later be easily changed if needed. Ironically, it was only after I did everything that I noticed that thezerologrepository includes some neat tricks for CLI apps, which I wasn't aware of. That's for a future version!As usual, feel free to use or ignore whatever you wish. It's a big PR!
Cheers,