From 0ce3e506bb877870ed3aa227c48c0fa75a96cf66 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Thu, 4 Aug 2022 00:10:56 +0300 Subject: [PATCH] custom pwd file path --- HISTORY.md | 3 +++ shard.yml | 2 +- src/pmng/app_settings.cr | 12 +++++++++++- src/pmng/functions/statistics.cr | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 81c67b1..ad007ac 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,9 @@ - ℹ️ - Information - ♻️ - Edited +## 0.2.6 - [03/08/2022] +- ➕ - Added enviopment variable for custom password path + ## 0.2.5 - [31/07/2022] - ➕ - Added timeout user input - ♻️ - Source file separated diff --git a/shard.yml b/shard.yml index 19eea01..94085fb 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: pmng -version: 0.2.5 +version: 0.2.6 authors: - Alexander Popov diff --git a/src/pmng/app_settings.cr b/src/pmng/app_settings.cr index 6ba776d..8af82b7 100644 --- a/src/pmng/app_settings.cr +++ b/src/pmng/app_settings.cr @@ -1,3 +1,13 @@ +def password_file + begin + file_path = "#{ENV["PMNG_PWD_FILE"]}" + file_path.to_s + rescue KeyError + file_path = "#{ENV["HOME"]}/.pwd.yml" + file_path.to_s + end +end + VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }} -PASSWORD_FILE_PATH = "#{ENV["HOME"]}/.pwd.yml" +PASSWORD_FILE_PATH = password_file() USER_INPUT_TIMEOUT = 60 diff --git a/src/pmng/functions/statistics.cr b/src/pmng/functions/statistics.cr index 5011345..d1824c6 100644 --- a/src/pmng/functions/statistics.cr +++ b/src/pmng/functions/statistics.cr @@ -1,4 +1,6 @@ module Pmng::Functions + extend self + class Statistics getter passwords : Array(Password) getter outdated : Int32