From 1485a193c8af2e89f046642b19481f0d0e2917ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87etin=20ARDAL?= Date: Wed, 8 Sep 2021 22:45:11 +0200 Subject: [PATCH] refactor(cpu_info): cmd usage info is a bash function --- CHANGELOG.md | 8 +++++++- system-config/cpu_info.sh | 14 ++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 778b105..a97b24e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,13 @@ Given a version number MAJOR.MINOR.PATCH: - MINOR version when adding functionality in a backwards compatible manner, - PATCH version when making backwards compatible bug fixes. -## [0.5.0] - 2021-09-03 +## [0.5.1] - 2021-09-08 + +## Changed + +- cpu_info.sh: use bash function for command usage information + +## [0.5.0] - 2021-09-08 ## Added diff --git a/system-config/cpu_info.sh b/system-config/cpu_info.sh index b1f09f9..759a132 100755 --- a/system-config/cpu_info.sh +++ b/system-config/cpu_info.sh @@ -6,6 +6,12 @@ # Also : https://apple.stackexchange.com/questions/238777/how-do-i-identify-which-cpu-a-macbook-uses/238789#238789 # Interesting output with `system_profiler SPHardwareDataType | grep Processor` +usage () { + echo "Usage information: ./cpu_info.sh [--short | --all | --help]" + echo "- short: print CPU Brand/Model, Core count, Thread count" + echo "- all: print all cpu information" +} + if [ -z "$1" ]; then sysctl -n machdep.cpu.brand_string sysctl -a | grep machdep.cpu.core_count | sed 's/machdep.//' @@ -17,11 +23,7 @@ elif [ "$1" = "--short" ]; then sysctl -a | grep machdep.cpu.core_count | sed 's/machdep.//' sysctl -a | grep machdep.cpu.thread_count | sed 's/machdep.//' elif [ "$1" = "--help" ]; then - echo "Usage information: ./cpu_info.sh [short|all]" - echo "- short: print CPU Brand/Model, Core count, Thread count" - echo "- all: print all cpu information" + usage else - echo "Usage information: ./cpu_info.sh [short|all]" - echo "- short: print CPU Brand/Model, Core count, Thread count" - echo "- all: print all cpu information" + usage fi