Tiny Bash script to print basic system information in consistent format.
TODO: GIF here
TODO: Here's a summary you can read in 30 seconds.
NOTE: These are documents to my future self.
- For my own use
- For learning bash script
NOTE: So, I will only support environments and software that I use frequently.
See: Supported Software:
section in proper7y
If you want to install proper7y command under ${HOME}/bin/
,
run commands on your terminal like:
DEST_DIR="${HOME}/bin"
cd "$(mktemp -d)" && \
curl -O https://raw.githubusercontent.com/rnazmo/proper7y/main/install.bash && \
chmod +x install.bash && \
./install.bash "$DEST_DIR"
To check that you installed it successfully:
"${HOME}/bin/proper7y"
- Download
proper7y
file from GitHub's raw page, specifying any version (Use a link like this one.) - Add the file to the environment PATH (optional)
- Add execute permission (like
chmod +x ./proper7y
) - Run (like
./proper7y
)
$ DEST_DIR="${HOME}/bin"
$ VERSION="v0.0.1"
$ cd "$DEST_DIR" && \
curl -O https://raw.githubusercontent.com/rnazmo/proper7y/"$VERSION"/proper7y && \
chmod +x ./proper7y
$ ./proper7y
TODO: Example result log here
Just run commands like the following in your terminal.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/rnazmo/proper7y/v0.3.0/proper7y)"
- Delete you old
proper7y
file. - Install a new version of 'proper7y'. (See Installation section.)
TODO:
TL;DR: Use install.bash
. Or Download proper7y
file directly with specifying a version
Don't download 'proper7y' (this indicates 'proper7y' as the file) directly from the main
branch,
but download it directly using a tag such as "v0.0.1".
Or, I highly recommend you to download 'proper7y' (this indicates 'proper7y' as the file) via install.bash
.
If you download install.bash
, it is also allowed from the main
branch.
If you do not specify the version (for example, if you download 'proper7y' (this indicates 'proper7y' as the file) directly from main
branch),
the version information of 'proper7y' (this indicates 'proper7y' as the project) itself in the output of the proper7y
(this 'proper7y' means as the file) command can be incorrect.
e.g.,
# BAD:
$ curl -O "https://raw.githubusercontent.com/rnazmo/proper7y/main/proper7y"
# GOOD:
$ curl -O "https://raw.githubusercontent.com/rnazmo/proper7y/v0.0.1/proper7y"
I highly recommend you to use install.bash
to avoid these mistakes.
# GOOD (Recommend)
$ DEST_DIR="${HOME}/bin"
$ cd /tmp && \
curl -O https://raw.githubusercontent.com/rnazmo/proper7y/main/install.bash && \
chmod +x ./install.bash && \
./install.bash "$DEST_DIR"
NOTE: These are documents to my future self.
- Simple usage (≒ option)
- Simple code
- Tiny code size
- Fewer files
- Minimum dependencies
- Simple documentation
- 重要な情報は
README.md
(とソースコード中のコメント) に集約する。 - 情報が散らばるのを避ける。
- Should not using 'Issues'
- Should not using 'Pull Requests'
- Shall not using 'Wikis'
- Shall not using wiki
- 重要な情報は
- Easy to maintain
- Support only environment/software that I use frequently
TODO: それぞれが "SHALL" なのか、"SHOULD" なのかを明記する。
Follow semantic versioning.
- 管理が面倒なので、「main」だけとする。(SHOULD)
- 「すぐに消すプルリク用の機能追加ブランチ」は作ってもよい。(SHOULD)
- 原則として、てきとうにゆるくやる
- ミスってもあまり気にせず。ゆるく
- For document only changes:
- Add 'docs: ' as a prefix (SHALL)
- When you bump a version of 'proper7y'
- Like this:
Bump a version to v0.0.3
(SHOULD)
- Like this:
- When you bump a version of devel-tools
- Like this:
Bump a version of shellcheck to v0.7.3
(SHOULD)
- Like this:
- When you bump a version of devel-tools
- TODO:
Avoid writing important information in Issues / Pull requests.
Because it is difficult to search and maintain the information written there.
特にルールは設けない。てきとうに。
Although not preferred, it is okay to have a mixture of English and Japanese (since the target reader of this document is my future self)
shellcheck, shfmt に従う。
Ref:
Shell scripting standards and style guidelines | GitLab
styleguide | Style guides for Google-originated open-source projects
koalaman/shellcheck: ShellCheck, a static analysis tool for shell scripts
mvdan/sh: A shell parser, formatter, and interpreter with bash support; includes shfmt
すべきではないが、(どうしても仕方がない場合のみ) 許可する。(対象ユーザーが自分のみなので)
Only the following machine are supported as development environments:
- 'debian-based Linux' && 'x64'
- Check if your machine meet the prerequisites
- Clone this repository under any directory on the machine. (
git clone [email protected]:rnazmo/proper7y.git
) - Install the dependencies using the scripts
make install-devel-tools
Just run:
make check-devel-tools-versions
- Edit and bump the versions in
/devel-tools/script/common.bash
. (likeSHELLCHECK_CURRENT_VERSION="v0.7.2"
,SHFMT_CURRENT_VERSION="v3.3.0"
) - Create a commit for the change with the commit message (like
Bump devel-tool version (shfmt): v3.5.1 -> v3.6.3
). - Push the commit (like
$ git push
).
Same as the how to install devel-tools. (Just run make install-devel-tools
).
NOTE: Install devel-tools before running lint.
make lint
NOTE: Install devel-tools before running format.
NOTE: This overwrite the files. Save it before running.
make format
make integ-test
- (We edited
proper7y
locally.) - Create a commit for the changes with any commit message.
- Push the changes (like
$ git push
). - Ensure that the CI to the commit passes. (And if the CI falls, we go back to step 0.)
- Run the script and bump the project version:
$ make bump-project
MEMO: The script do following:
- Edit and bump a version of
VERSION="v0.0.X"
inproper7y
,install.bash
, and/devel-tools/script/common.bash
. (Don't forget to follow semantic versioning!) - Create a commit for the change with the commit message (like
Bump a version to v0.0.3
). - Add a Git tag to the commit (like
$ git tag v0.0.3
). - Push the commit and tags (like
$ git push --atomic origin main v0.0.3
. ref: https://stackoverflow.com/a/3745250).
- Check "prerequisites exists?", "the os is supported os?":
- proper7y: 最初に OS を特定し、未対応の OS の場合にはエラーを返して終了させる
- main 関数の最初で OS を特定し、その情報を変数に保存しておく
- コマンドの exit status を整える。(正常終了で 0 を返す、など)
- proper7y: 最初に OS を特定し、未対応の OS の場合にはエラーを返して終了させる
- testing, ci:
- Support Manjaro Linux
- Support Manjaro Linux as development environment
- CI のテスト環境に Manjaro (Arch Linux) を追加
- Add unit test?
ShellSpec
?- スクリプトの特性上、ユニットテストでテストできる範囲狭そう
- Support Manjaro Linux
- docs:
- Update the convention
- Scope:
Lines 163 to 166 in 5d25e10
- やっぱり、変更が大きいときは branch 使いたいかも。
- 「なるべく
main
だけの状態を維持することが望ましい。ただし、機能追加などで一時的なブランチを作るのは全く構わない」などと改定する? - Google Style Guide
- Conventional Commits
- Scope:
- Update the convention
v1.0.0
までに実装すべきもの(足りないもの)を列挙しておく- 対応する環境・対象とするソフトウェアをはっきりさせる
- 対応する環境は?:
- OS: ubuntu, kali, macos, ...
- shell: bash, zsh
- 対応する環境は?:
- オプション機能は作る?どうする?
- README.md の内容を整える
- Refine README.md (内容が重複しているところとかある)
install.bash
がある理由を書いておく- これを使うと常に同じコマンドで最新版をインストールできる。使わない場合、明示的にバージョンを指定しなければならなくて面倒。(特に、別のスクリプト中で 'property' をインストールする場合、バージョン管理しなくてはならず面倒)
- ref: https://github.com/rnazmo/proper7y/blob/6b77aee0debf25f4d6f6a1aee8224c84470a765f/README.md#do-not-download-install-proper7y-without-specifying-the-version
- 書き方はここが参考になりそう:
- Add following texts to
README.md
-
In this document,
proper7y
indicates the file, 'proper7y' indicates the project (≒ the repository) and$ proper7y
indicates the command on your console.
-
- Add GIF image to
README.md
- using
asciinema
?
- using
- About supported OS (?)
Should I rewrite with Golang?- このアプリを作る&メンテする目的の 1 つは
For learning bash script
である。よって、Bash script でやるべき。どうしても辛くなって Golang などで作り直したい場合は、アプリの目的も含めて見直すこと
- このアプリを作る&メンテする目的の 1 つは
- Windows の対応は大変だしコードが複雑になる。対応したいなら、 'proper7y4win とでも別リポジトリを作ってそっちでやる (powershell スクリプト?)
- 対応する環境・対象とするソフトウェアをはっきりさせる
- devel-tools が最新かどうか、CI (github actions)でチェック?
- Run the script
check-devel-tools-versions.bash
on CI ?- Trigger: weekly (Can I use https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events ?)
- 自動で Pull Request 作成するところまでやる? (dependabot みたいに)
- 実装や権限管理面倒じゃない?大丈夫?
- そもそも Pull Request はあまり使いたくないのでは?
- でもあると便利だし、Bot に限れば Pull Request 使っても良いかも。
- Add the badge to
README.md
. (The text is likedependencies latest
?)
- Run the script
- Add ChangeLog
-i
: Specify indent size-d
: Error when the formatting differs
Ref:
- Shell scripting standards and style guidelines | GitLab
- sh/shfmt.1.scd at f33507475241da6fc37b972d825c351b94300bab · mvdan/sh
Example:
shfmt -i 2 -d ./proper7y ./install.bash
-w
: Write result to file instead of stdout.
make lint
make format
make lint
make format
make integ-test