From 8f90574b08765f62c8f52bdc89af3128b100690c Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Mon, 3 Jan 2022 21:21:30 +0300 Subject: [PATCH] =?UTF-8?q?Init=20=F0=9F=8F=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 15 ++++++ .gitignore | 10 ++++ LICENSE | 10 ++++ README.md | 27 +++++++++++ shard.lock | 2 + shard.yml | 15 ++++++ spec/passw0rd_manager_spec.cr | 9 ++++ spec/spec_helper.cr | 2 + src/passw0rd_manager.cr | 87 +++++++++++++++++++++++++++++++++++ 9 files changed, 177 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 shard.lock create mode 100644 shard.yml create mode 100644 spec/passw0rd_manager_spec.cr create mode 100644 spec/spec_helper.cr create mode 100644 src/passw0rd_manager.cr diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ba8cdba --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[{*.cr,shards.yml}] +indent_style = space +indent_size = 2 + +[{*.ecr,*.json}] +indent_style = tab +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..833c5aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/docs/ +/lib/ +/bin/ +/.shards/ +*.dwarf + +/src/views/ + +data.json +pwd.yml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cde4ac6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,10 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. + +In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..9bb74d2 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# passw0rd_manager + +TODO: Write a description here + +## Installation + +TODO: Write installation instructions here + +## Usage + +TODO: Write usage instructions here + +## Development + +TODO: Write development instructions here + +## Contributing + +1. Fork it () +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create a new Pull Request + +## Contributors + +- [Alexander Popov](https://github.com/your-github-user) - creator and maintainer diff --git a/shard.lock b/shard.lock new file mode 100644 index 0000000..4f3e149 --- /dev/null +++ b/shard.lock @@ -0,0 +1,2 @@ +version: 2.0 +shards: {} diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..8d41161 --- /dev/null +++ b/shard.yml @@ -0,0 +1,15 @@ +name: passw0rd_manager +version: 0.1.0 + +authors: + - Alexander Popov + +targets: + passw0rd_manager: + main: src/passw0rd_manager.cr + +dependencies: + +crystal: 1.2.2 + +license: MIT diff --git a/spec/passw0rd_manager_spec.cr b/spec/passw0rd_manager_spec.cr new file mode 100644 index 0000000..b0d355b --- /dev/null +++ b/spec/passw0rd_manager_spec.cr @@ -0,0 +1,9 @@ +require "./spec_helper" + +describe Passw0rdManager do + # TODO: Write tests + + it "works" do + false.should eq(true) + end +end diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr new file mode 100644 index 0000000..347599b --- /dev/null +++ b/spec/spec_helper.cr @@ -0,0 +1,2 @@ +require "spec" +require "../src/passw0rd_manager" diff --git a/src/passw0rd_manager.cr b/src/passw0rd_manager.cr new file mode 100644 index 0000000..0deb1dd --- /dev/null +++ b/src/passw0rd_manager.cr @@ -0,0 +1,87 @@ +require "yaml" +require "colorize" + +class Password + include YAML::Serializable + + @[YAML::Field(key: "url")] + property url : String + @[YAML::Field(key: "email")] + property email : String + @[YAML::Field(key: "login")] + property login : String + @[YAML::Field(key: "password")] + property password : String + @[YAML::Field(key: "desc")] + property desc : String + @[YAML::Field(key: "profile_url")] + property profile_url : String + @[YAML::Field(key: "update")] + property update : Int32 +end + +VERSION = "0.1.0" + +if !File.exists?("pwd.yml") + 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 + new_array << Password.from_yaml(yaml[count].to_yaml) + count += 1 +end + +while true + print "Enter URL (or :q for exit)\n> " + password_string = gets + + if password_string.to_s == ":q" + puts "Bye! 👋🏻" + + exit(0) + elsif password_string.to_s == ":h" + puts "Help:\n-----" + puts ":s - return stats" + + puts + elsif password_string.to_s == ":s" + print "Elements: " + puts new_array.size + + puts + end + + new_array.each do |item| + if item.url.includes?(password_string.to_s) + puts item.url.colorize(:magenta).mode(:blink) + + if !item.email.blank? + puts item.email.colorize(:red) + end + if !item.login.blank? + puts item.login.colorize(:yellow) + end + if !item.password.blank? + puts item.password.colorize(:red).back(:red) + end + if !item.desc.blank? + puts item.desc.colorize(:cyan) + end + if !item.profile_url.blank? + puts item.profile_url.colorize(:green) + end + + puts "---".colorize(:dark_gray) + end + end + + puts +end