Allow brew install of command line tools made in Python

tl;dr

  1. Create a repository called homebrew-[name]
  2. Go on (explained from now on)
  3. brew tap [user name]/[name]
  4. brew install [name]

Gonyo Gonyo

This time, I prepared a simple script that just converts dollars to yen. Flow until Web API is dropped into a command line tool using Python This will allow you to brew install

First, create a repository named homebrew-usdex and clone it.

$ git clone https://github.com/kei-sato/homebrew-usdex.git
$ cd homebrew-usdex

Create a file called [name] .rb in the root

usdex.rb


class Usdex < Formula
  desc "Exchange usd to any currency, or any currency to usd"
  homepage "https://gist.github.com/kei-sato/98675769952ec7538d6a"
  url "https://gist.githubusercontent.com/kei-sato/98675769952ec7538d6a/raw/3b041cdd0e93c93986b15d158bff158927cb84b1/usdex"
  sha256 "976ae1b2066b2cb40be934fb2265ccd3bd8489f78683c6eaecba29c50edd4758"
  version "1.0.0"

  def install
    bin.install "usdex"
  end
end

Then push, tap, install

$ git push origin master
$ brew tap kei-sato/usdex
$ brew install usdex
$ usdex -p 2.5 -v
1(USD) => 122.54078(JPY)
2.5(USD) => 306.35195(JPY)

SHA256? SHA-256 (Secure Hash Algorithm 256-bit)

SHA-256 is one of the calculation procedures (algorithms) for finding the "hash value", which is a characteristic value of fixed length, from the original text of arbitrary length.

Can be generated with openssl

$ echo "hello" | openssl dgst -sha256
5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
$ echo "hello, world" | openssl dgst -sha256
853ff93762a06ddbf722c4ebe9ddd66d8f63ddaea97f521c3ecc20da7c976020
$ echo "hello, world" > /tmp/hello
$ openssl dgst -sha256 /tmp/hello
SHA256(/tmp/hello)= 853ff93762a06ddbf722c4ebe9ddd66d8f63ddaea97f521c3ecc20da7c976020

Generate a hash value for the file you download with Homebrew

$ openssl dgst -sha256 usdex
SHA256(usdex)= 976ae1b2066b2cb40be934fb2265ccd3bd8489f78683c6eaecba29c50edd4758

Reference site

http://deeeet.com/writing/2014/05/20/brew-tap/ http://qiita.com/masawada/items/484bbf83ef39cad7af74

Recommended Posts

Allow brew install of command line tools made in Python
Summary of tools used in Command Line vol.8
Summary of tools used in Command Line vol.5
Decompose command arguments in one line in Python
Template for creating command line applications in Python
How to receive command line arguments in Python
Summary of tools needed to analyze data in Python
Specify a subcommand as a command line argument in Python
Existence check of external command in Python (like `which`)
Fizzbuzz in Python (in one line)
Use Python 3 introduced with command line tools on macOS Catalina
Execute external command in python
Equivalence of objects in Python
Try LINE Notify in Python
Install multiple versions of Python
Decrypt one line of code in Python lambda, map, list
External command execution in Python
Implementation of quicksort in Python
Python install in 2 lines @Windows
Google search for the last line of the file in Python
After updating to MacOS Catalina, install Xcode Command Line Tools and change from Python 2.7 series to 3.7 series (bash)
Create another version of Python conda environment with one command line
python Note: Determine if command line arguments are in the list
Difference in behavior of transparent Frame made with tkinter in pyinstaller [Python]
How to get a string from a command line argument in python
Read the standard output of a subprocess line by line in Python
Command line argument processing (Python docopt)
Pixel manipulation of images in Python
Make python segfault in one line
Hit a command in Python (Windows)
Run shell command / python in R
Division of timedelta in Python 2.7 series
Install scrapy in python anaconda environment
MySQL-automatic escape of parameters in python
Numer0n with items made in Python
Handling of JSON files in Python
Install GoLang in goenv of anyenv
In the python command python points to python3.8
Implementation of life game in Python
Waveform display of audio in Python
Windows10: Install MeCab library in python
install tensorflow in anaconda + python3.5 environment
I can't install scikit-learn in Python
Law of large numbers in python
Implementation of original sorting in Python
Reversible scrambling of integers in Python
I tried Line notification in Python
[Introduction] Insert line breaks in Python 3
Implemented in 1 minute! LINE Notify in Python
Get options in Python from both JSON files and command line arguments
I made a program to check the size of a file in Python
A note I looked up to make a command line tool in Python
Conversion of string <-> date (date, datetime) in Python
CGI server (1) python edition in one line
Check the behavior of destructor in Python
(Bad) practice of using this in Python
General Theory of Relativity in Python: Introduction
I made a payroll program in Python!
[LLDB] Create your own command in Python
Output tree structure of files in Python
Display a list of alphabets in Python 3