For now, the tool only supports searching for exact values of color components as ints, floats or hexadecimals, without conversion between settings like content type (sRGB, Display P3, Gray Gamma 2.2 etc.), and ignoring some other settings like Gamut etc.
The tool can be used like this from terminal:
hexcode #ffa500
...where #ffa500
is a hex color code, with or without #
, case-insensitive.
This way hexcode
will recursively search for the color assets matching the hex rgb value, starting from current directory. The output will be one or more matching color set names, or a message notifying that it haven't found an asset with the given color. The command also has some very simple error handling and might exit with error.
More arguments and options will be added in the future with new features, they can be found using the --help
flag.
- Clone the repository to your machine
- Assuming the folder name "hexcode" has not changed, run in terminal:
cd hexcode
Then run the following:
swift build -c release
mv .build/release/hexcode /usr/local/bin
(you might need sudo
before the mv
command, depending on your machine's configuration)
- Run
which hexcode
to make sure it is now visible
Alternatively, it can be moved to some directory other than /usr/local/bin
, just make sure that directory is included in $PATH
if you want it visible from anywhere in terminal.
Or you can just run it as an executable Swift package without installation, using Swift Package Manager commands.
From the root of the repository, run the following command:
sudo make install
If you want to install it into a directory other than default /usr/local/bin
, replace it in the Makefile
with your target directory.
Just make sure it's added to the PATH.
From the hexcode
directory (or passing it as --package-path
), the command can be run as executable package without previous installation, for example:
swift run hexcode e8de2a --directory=$HOME/Documents/myProject
- "If it is not tested, I will send it back."
- "If tests don't pass, I will send it back."
Tests should work both from Xcode (Cmd+U after opening Package.swift
) and Terminal:
swift test
Core logic must be covered with tests that help decrease regression when developing new features, and also help understand how the app works.