Init 🏁

This commit is contained in:
Alexander Popov 2022-01-03 21:21:30 +03:00
commit 8f90574b08
9 changed files with 177 additions and 0 deletions

15
.editorconfig Normal file
View File

@ -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

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf
/src/views/
data.json
pwd.yml

10
LICENSE Normal file
View File

@ -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 <http://unlicense.org/>

27
README.md Normal file
View File

@ -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 (<https://github.com/your-github-user/passw0rd_manager/fork>)
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

2
shard.lock Normal file
View File

@ -0,0 +1,2 @@
version: 2.0
shards: {}

15
shard.yml Normal file
View File

@ -0,0 +1,15 @@
name: passw0rd_manager
version: 0.1.0
authors:
- Alexander Popov <iiiypuk@iiiypuk.me>
targets:
passw0rd_manager:
main: src/passw0rd_manager.cr
dependencies:
crystal: 1.2.2
license: MIT

View File

@ -0,0 +1,9 @@
require "./spec_helper"
describe Passw0rdManager do
# TODO: Write tests
it "works" do
false.should eq(true)
end
end

2
spec/spec_helper.cr Normal file
View File

@ -0,0 +1,2 @@
require "spec"
require "../src/passw0rd_manager"

87
src/passw0rd_manager.cr Normal file
View File

@ -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