From 866bd9d2d0994504389cc24efad899b8fe8330e1 Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Fri, 10 Apr 2020 07:53:38 -0500 Subject: [PATCH] Clean up kitchen_sink.sh --- README.md | 2 ++ pigeon-cli | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7e5fa10..4b888a4 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`. - [X] Message.ingest should be the only code path to message authoring. - [X] Don't allow any type of whitespace in `kind` or `string` keys. Write a test for this. - [ ] Make all methods private except those required for the CLI. + - [ ] Run Flog / Flay and friends to find duplications. Will aid in port to other languages. + - [ ] Make CLI names consistent with API names. Eg: find vs. read. - [ ] Add Lipmaa links like the Bamboo folks do. - [ ] Create regexes in ::Lexer using strings and Regexp.new() for cleaner regexes. - [ ] Make the switch to LevelDB, RocksDB, [UNQLite](https://unqlite.org/features.html) or similar (currently using Ruby PStore). diff --git a/pigeon-cli b/pigeon-cli index 8070851..c37df6b 100755 --- a/pigeon-cli +++ b/pigeon-cli @@ -87,7 +87,7 @@ module Pigeon desc "create", "Begin a new Pigeon message" def create(kind) - puts Pigeon::Draft.create(kind: kind).render + puts Pigeon::Draft.create(kind: kind).render_as_draft end desc "append", "Add a key/value pair to the current DRAFT" @@ -106,7 +106,7 @@ module Pigeon def show(message_id = "") if message_id == "" - puts Pigeon::Draft.current.render + puts Pigeon::Draft.current.render_as_draft else bail("You must create a draft first") end @@ -115,9 +115,7 @@ module Pigeon desc "sign", "Commit current DRAFT to local feed." def sign - draft = Pigeon::Draft.current - message = Pigeon::Message.publish(draft) - puts message.render + puts Pigeon::Draft.current.publish.render end end @@ -133,7 +131,7 @@ module Pigeon desc "find", "Find a pigeon message in the local DB" def find(multihash) - puts Pigeon::Storage.current.find_message(multihash).render + puts Pigeon::Storage.current.read_message(multihash).render end desc "find-all", "Find a pigeon message in the local DB" @@ -151,7 +149,8 @@ module Pigeon def last me = Pigeon::LocalIdentity.current store = Pigeon::Storage.current - multihash = store.get_message_by_depth(me.multihash, store.message_count - 1) + mcount = store.get_message_count_for(me.multihash) + multihash = store.get_message_by_depth(me.multihash, mcount - 1) puts multihash end end @@ -160,13 +159,16 @@ module Pigeon desc "status", "Show various information about the `.pigeon` directory" def status + store = Pigeon::Storage.current + me = Pigeon::LocalIdentity.current.multihash + mcount = store.get_message_count_for(me) puts " -`. Pigeon Protocol Ruby Client - '( @ > Version: #{Pigeon::VERSION} - _) ( Peers: #{Pigeon::Storage.current.all_peers.count} - / ) Blocked: #{Pigeon::Storage.current.all_blocks.count} - /_,' / Logs: #{Pigeon::Storage.current.message_count} - \\ / Ident: #{Pigeon::LocalIdentity.current.multihash} + '( @ > Version: #{Pigeon::VERSION} + _) ( Peers: #{store.all_peers.count} + / ) Blocked: #{store.all_blocks.count} + /_,' / Published: #{mcount} + \\ / Ident: #{me} ===m" "m=== " end