Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Rename registry items to registered-machine
Browse files Browse the repository at this point in the history
  • Loading branch information
Merle Breitkreuz committed Jun 6, 2019
1 parent 9cb697a commit 849899e
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 160 deletions.
96 changes: 48 additions & 48 deletions bin/rad-registry
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@
Usage:
rad registry list [--unread]
rad registry new
rad registry [show | delete | mark-read | mark-unread] <project-number>
rad registry [show | delete | mark-read | mark-unread] <registered-machine-number>
rad registry all-read
rad registry init
rad registry set <registry-id>
rad registry help

list - Lists all projects
If the option '--unread' is appended, only unread projects
list - Lists all registered Radicle machines
If the option '--unread' is appended, only unread machines
are listed.
Unread projects are marked with a * after the timestamp.
new - Register a new project in $EDITOR
show - Show a project
show-id - Show the project id
delete - Delete a project
Unread machines are marked with a * after the timestamp.
new - Register a new Radicle machine in $EDITOR
show - Show a registered Radicle machine
show-id - Show the registered Radicle machine id
delete - Delete a Radicle machine from the registry
This command is restricted to the maintainer of the registry
and the registrant.
mark-read - Mark project as read
mark-unread - Mark project as unread
all-read - Mark all projects as read
mark-read - Mark registered Radicle machine as read
mark-unread - Mark registered Radicle machine as unread
all-read - Mark all registered Radicle machines as read
init - Initialize a new registry machine
set - Set the registry that is used for the commands instead of
the default. Delete the file to use the default registry.
Expand All @@ -69,64 +69,64 @@
(fn [error]
(parse-failure error help)))

(def get-project
"Returns the project of given number `n`."
(def get-registered-machine
"Returns the machine of given number `n`."
(fn [n machine]
(items/verify-item-number n (list-projects machine) :project)))
(items/verify-item-number n (list-registered-machines machine) :registered-machine)))

(def show-project!
"Shows a single PROJECT `n`"
(def show-registered-machine!
"Shows a single MACHINE `n`"
(fn [n machine]
(def project (get-project n machine))
(put-str! (items/pretty-item-view (items/enrich-item machine project)))
(def registered-machine (get-registered-machine n machine))
(put-str! (items/pretty-item-view (items/enrich-item machine registered-machine)))
(newness/mark-read! machine n)))

(def show-project-id!
"Shows the id of a single PROJECT `n`"
(def show-registered-machine-id!
"Shows the id of a single MACHINE `n`"
(fn [n machine]
(def project (get-project n machine))
(put-str! (lookup :project-id project))
(def registered-machine (get-registered-machine n machine))
(put-str! (lookup :registered-machine-id registered-machine))
(newness/mark-read! machine n)))

(def delete-project
(def delete-registered-machine
(fn [n machine]
(catch 'daemon-error
(do
(get-project n machine)
(delete-project! machine {:project-number n})
(put-str! (string-append "Project #" (show n) " has been deleted."))
(get-registered-machine n machine)
(delete-registered-machine! machine {:registered-machine-number n})
(put-str! (string-append "Radicle machine #" (show n) " has been deleted."))
(newness/mark-read! machine n))
(fn [_]
(put-str! (error/state-change-failure :project "deleted"))
(put-str! (error/state-change-failure :registered-machine "deleted"))
(exit! 1)))))

(def list
(fn [machine options]
(def projects (values (list-projects machine)))
(items/list-items-plain machine options projects :project)))
(def registered-machines (values (list-registered-machines machine)))
(items/list-items-plain machine options registered-machines :registered-machine)))

(def prompt-for-metadata!
(fn []
(def name (prompt-non-empty!
"? What's the name of your project: "
"? What's the name of your Radicle machine: "
\(not (eq? ? ""))
"Project name can't be empty!"))
(def desc (prompt! "? Briefly describe the project: "))
"Radicle machine name can't be empty!"))
(def desc (prompt! "? Briefly describe the Radicle machine: "))
(def id (prompt-non-empty!
"? What's the id of your project: "
"? What's the id of your Radicle machine: "
\(not (eq? ? ""))
"Project id can't be empty!"))
"Radicle machine id can't be empty!"))
(def labels (prompt! "? Do you want to add any labels (comma seperated): "))
{:name name :description desc :project-id id :labels (split-by (fn [x] (eq? x ",")) labels)}))
{:name name :description desc :registered-machine-id id :labels (split-by (fn [x] (eq? x ",")) labels)}))

(def new-project
(def register-machine
(fn [machine]
(def meta (prompt-for-metadata!))
(def author {:git-username (get-git-username!)})
(match (register-project! machine (simple-project (<> meta author)))
['n] (do (put-str! (string-append "Created project #" (show n) " in " machine))
(match (register-machine! machine (simple-registered-machine (<> meta author)))
['n] (do (put-str! (string-append "Registered Radicle machine #" (show n) " in " machine))
(newness/mark-read! machine n))
_ (put-str! (error/no-number-returned :project)))))
_ (put-str! (error/no-number-returned :registered-machine)))))

(def cmd-options
[
Expand All @@ -139,14 +139,14 @@

(def args (get-args!))

(def whole-project-num
(def whole-registered-machine-num
(fn [action num-str f]
(whole-num help :project action num-str f)))
(whole-num help :registered-machine action num-str f)))

(def mark-all-read!
(fn [machine]
(map (fn [i] (newness/mark-read! machine (lookup :number i)))
(values (list-projects machine)))))
(values (list-registered-machines machine)))))

(def new-registry!
(fn []
Expand All @@ -164,14 +164,14 @@
(fn []
(match args
(/list-cmd 'options) (list (machine-name) options)
(/cmd-0 "new" help) (new-project (machine-name))
(/cmd-0 "new" help) (register-machine (machine-name))
(/cmd-0 "init" help) (new-registry!)
(/cmd-1 "set" 'n help) (set-registry! n)
(/cmd-1 "delete" 'n help) (whole-project-num "delete" n (fn [n] (delete-project n (machine-name))))
(/cmd-1 "show" 'n help) (whole-project-num "show" n (fn [n] (show-project! n (machine-name))))
(/cmd-1 "show-id" 'n help) (whole-project-num "show-id" n (fn [n] (show-project-id! n (machine-name))))
(/cmd-1 "mark-read" 'n help) (whole-project-num "mark as read" n (fn [n] (newness/mark-read! (machine-name) n)))
(/cmd-1 "mark-unread" 'n help) (whole-project-num "mark as unread" n (fn [n] (newness/mark-unread! (machine-name) n)))
(/cmd-1 "delete" 'n help) (whole-registered-machine-num "delete" n (fn [n] (delete-registered-machine n (machine-name))))
(/cmd-1 "show" 'n help) (whole-registered-machine-num "show" n (fn [n] (show-registered-machine! n (machine-name))))
(/cmd-1 "show-id" 'n help) (whole-registered-machine-num "show-id" n (fn [n] (show-registered-machine-id! n (machine-name))))
(/cmd-1 "mark-read" 'n help) (whole-registered-machine-num "mark as read" n (fn [n] (newness/mark-read! (machine-name) n)))
(/cmd-1 "mark-unread" 'n help) (whole-registered-machine-num "mark as unread" n (fn [n] (newness/mark-unread! (machine-name) n)))
(/cmd-0 "all-read" help) (mark-all-read! (machine-name))
(/cmd-help) (put-str! help)
(/cons 'cmd _) (cmd-parse-failure (error/unknown-command cmd))
Expand Down
38 changes: 19 additions & 19 deletions rad/monadic/items.rad
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@
(def item-title
(fn [item-flag]
(match item-flag
:issue "title"
:patch "commit"
:project "project name")))
:issue "title"
:patch "commit"
:registered-machine "Radicle machine name")))

(def pretty-table-header
(fn [item-flag]
(def title (item-title item-flag))
(match item-flag
:project (string-append
(wrap-cell "#" :number)
(wrap-cell title :title)
(wrap-cell "author" :author)
(wrap-cell "updated" :modified-at))
_ (string-append
(wrap-cell "state" :state)
(wrap-cell "#" :number)
(wrap-cell title :title)
(wrap-cell "author" :author)
(wrap-cell "updated" :modified-at)))))
:registered-machine (string-append
(wrap-cell "#" :number)
(wrap-cell title :title)
(wrap-cell "author" :author)
(wrap-cell "updated" :modified-at))
_ (string-append
(wrap-cell "state" :state)
(wrap-cell "#" :number)
(wrap-cell title :title)
(wrap-cell "author" :author)
(wrap-cell "updated" :modified-at)))))

(def pretty-modified-at
(fn [i]
Expand Down Expand Up @@ -171,7 +171,7 @@
:name tit
:description desc
:labels ls
:project-id id
:registered-machine-id id
:username un
:created-at c-a}
(string-replace
Expand All @@ -180,7 +180,7 @@
(string-append
(pretty-headline i) "\n\n"
"**Labels:** " (show ls) "\n\n"
"**Project ID:** " (show id) "\n\n"
"**Radicle machine ID:** " (show id) "\n\n"
desc
))
'{:patch p
Expand All @@ -196,9 +196,9 @@
(def items-name
(fn [item-flag]
(match item-flag
:issue "issues"
:patch "patches"
:project "projects")))
:issue "issues"
:patch "patches"
:registered-machine "Radicle machines")))

(def add-username
(fn [d]
Expand Down
Loading

0 comments on commit 849899e

Please sign in to comment.