diff --git a/.gitignore b/.gitignore index 5bb1a51..0bb75ea 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,3 @@ /bin/ /.shards/ *.dwarf - -pwd.yml diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 0000000..e01d228 --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,10 @@ +## Legend +- 🐛 - Bug +- ✔ī¸ - Fixed +- ❌ - Removed +- ➕ - Added +- ℹī¸ - Information +- â™ģī¸ - Edited + +## 0.2.0 - [04/01/2022] +- reading passwords file from program folder (portable mode) diff --git a/src/pmng.cr b/src/pmng.cr index f5bf709..b1724e0 100644 --- a/src/pmng.cr +++ b/src/pmng.cr @@ -25,7 +25,7 @@ VERSION = "0.1.0" begin OptionParser.parse do |parser| - parser.banner = "Welcome to The Beatles App!" + parser.banner = "pmng -- ver.: #{VERSION}\nThe very simple password manager for humans\n" parser.on "-v", "--version", "Show version" do puts "Version #{VERSION}" @@ -50,16 +50,21 @@ rescue ex puts ex.message, "" end -if !File.exists?("pwd.yml") +password_file_path = PROGRAM_NAME.split("/") +password_file_path.pop +password_file_path.insert(-1, "pwd.yml") +password_file_path = password_file_path.join("/") + +if File.exists?(password_file_path) + yaml = File.open(password_file_path) do |file| + YAML.parse(file) + end +else puts "No password.yml file exists." exit(1) end -yaml = File.open("pwd.yml") do |file| - YAML.parse(file) -end - new_array = [] of Password count = 0 while count < yaml.size