Skip to content

Tiny Bash script to print basic system information in consistent format for my own use.

License

Notifications You must be signed in to change notification settings

rnazmo/proper7y

Repository files navigation

proper7y

Static Test Integration Test

Tiny Bash script to print basic system information in consistent format.

TODO: GIF here

TL;DR

TODO: Here's a summary you can read in 30 seconds.

Documentation for users

NOTE: These are documents to my future self.

Purpose of this project

  • For my own use
  • For learning bash script

NOTE: So, I will only support environments and software that I use frequently.

Supported softwares

See: Supported Software: section in proper7y

Installation

Using Script (recommended) - Install the latest release version

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"

Manually - Install the specified release version

  1. Download proper7y file from GitHub's raw page, specifying any version (Use a link like this one.)
  2. Add the file to the environment PATH (optional)
  3. Add execute permission (like chmod +x ./proper7y)
  4. 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

Using without installation

Just run commands like the following in your terminal.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/rnazmo/proper7y/v0.3.0/proper7y)"

How to bump a version of my 'proper7y'

  1. Delete you old proper7y file.
  2. Install a new version of 'proper7y'. (See Installation section.)

Examples

TODO:

Notes

Do not download (install) 'proper7y' without specifying the version

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"

Documentation for developers

NOTE: These are documents to my future self.

Policies

  • 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

Conventions

TODO: それぞれが "SHALL" なのか、"SHOULD" なのかを明記する。

Versioning

Follow semantic versioning.

Branch

  • 管理が面倒なので、「main」だけとする。(SHOULD)
  • 「すぐに消すプルリク用の機能追加ブランチ」は作ってもよい。(SHOULD)

Commit message

  • 原則として、てきとうにゆるくやる
    • ミスってもあまり気にせず。ゆるく
  • 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)
  • When you bump a version of devel-tools
    • Like this: Bump a version of shellcheck to v0.7.3 (SHOULD)
  • When you bump a version of devel-tools
    • TODO:

Issues / Pull requests

Avoid writing important information in Issues / Pull requests.

Because it is difficult to search and maintain the information written there.

Issue / Pull request title

特にルールは設けない。てきとうに。

Documentation

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)

Code Style for Bash Script (Lint, Format)

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

Force push to the remote repo

すべきではないが、(どうしても仕方がない場合のみ) 許可する。(対象ユーザーが自分のみなので)

Prerequisite

Only the following machine are supported as development environments:

  • 'debian-based Linux' && 'x64'

How to setup your development environment

  1. Check if your machine meet the prerequisites
  2. Clone this repository under any directory on the machine. (git clone [email protected]:rnazmo/proper7y.git)
  3. Install the dependencies using the scripts

How to install devel-tools

make install-devel-tools

How to bump a version of devel-tools

Using script

Just run:

make check-devel-tools-versions

Manually

  1. Edit and bump the versions in /devel-tools/script/common.bash. (like SHELLCHECK_CURRENT_VERSION="v0.7.2", SHFMT_CURRENT_VERSION="v3.3.0")
  2. Create a commit for the change with the commit message (like Bump devel-tool version (shfmt): v3.5.1 -> v3.6.3).
  3. Push the commit (like $ git push).

How to upgrade a version of devel-tools

Same as the how to install devel-tools. (Just run make install-devel-tools).

How to run lint

NOTE: Install devel-tools before running lint.

make lint

How to run format

NOTE: Install devel-tools before running format.

NOTE: This overwrite the files. Save it before running.

make format

How to run integration-test

make integ-test

How to bump a version of 'proper7y' (versioning workflow)

  1. (We edited proper7y locally.)
  2. Create a commit for the changes with any commit message.
  3. Push the changes (like $ git push).
  4. Ensure that the CI to the commit passes. (And if the CI falls, we go back to step 0.)
  5. Run the script and bump the project version: $ make bump-project

MEMO: The script do following:

  1. Edit and bump a version of VERSION="v0.0.X" in proper7y, install.bash, and /devel-tools/script/common.bash. (Don't forget to follow semantic versioning!)
  2. Create a commit for the change with the commit message (like Bump a version to v0.0.3).
  3. Add a Git tag to the commit (like $ git tag v0.0.3).
  4. Push the commit and tags (like $ git push --atomic origin main v0.0.3 . ref: https://stackoverflow.com/a/3745250).

TODO

Priority: ☆☆☆

Priority: ☆

Memo

Linting

Options of shfmt

  • -i : Specify indent size
  • -d : Error when the formatting differs

Ref:

Example:

shfmt -i 2 -d ./proper7y ./install.bash

Formatting

Options of shfmt

  • -w: Write result to file instead of stdout.

Pre-commit

make lint
make format

Pre-push

make lint
make format
make integ-test

About

Tiny Bash script to print basic system information in consistent format for my own use.

Resources

License

Stars

Watchers

Forks