-
Notifications
You must be signed in to change notification settings - Fork 32
Rad registry #652
base: v2.0.0
Are you sure you want to change the base?
Rad registry #652
Conversation
bin/rad-registry
Outdated
|
||
;; TODO Replace with server hosted machine | ||
(def default-machine-name | ||
"The default registry machine." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't have to be a function. Changing it.
bin/rad-registry
Outdated
:nothing (default-machine-name) | ||
[:just 'r] r))) | ||
|
||
(def valid-states ["open" "closed"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to keep this as state? Why not just delete projects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove the state
add commands for deleting projects.
bin/rad-registry
Outdated
|
||
(def valid-states ["open" "closed"]) | ||
|
||
(def status-opts ["--filter-by-state" "--state" "-s"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to the above, I don't really see the point in being able to filter. If you removed a project, you shouldn't be able to see it at all.
bin/rad-registry
Outdated
Usage: | ||
rad registry list " list-opts-help " | ||
rad registry new | ||
rad registry [show | close | mark-read | mark-unread] <project-number> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than close
, I'd call it remove
or delete
.
bin/rad-registry
Outdated
(catch 'daemon-error | ||
(do | ||
(items/verify-item-number n (list-projects machine) :project) | ||
(simple-edit-project! machine n {:state :closed}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to use this three times. Maybe make a helper function?
rad/prelude/error-messages.rad
Outdated
@@ -82,11 +82,11 @@ | |||
|
|||
(def uppercase-item | |||
(fn [item] | |||
(lookup item {:issue "Issue" :patch "Patch"}))) | |||
(lookup item {:issue "Issue" :patch "Patch" :project "Project"}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(def uppercase-item [item]
(titlecase (lowercase-item item))
You'll need to add some sort of pattern matching or similar functionality to implement titlecase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(See above) The flag and item name does not match in this way anymore.
rad/prelude/io.rad
Outdated
@@ -260,6 +260,16 @@ process exited normally and `[:error n]` otherwise. Example: `(process! | |||
(write-handle! (stderr!) prompt) | |||
(read-line-handle! (stdin!)))) | |||
|
|||
(def-rec prompt-non-empty! | |||
"Same as `prompt!`, but repeats id the input empty." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Same as `prompt!`, but repeats id the input empty." | |
"Same as `prompt!`, but repeats if the input is empty." |
rad/prelude/io.rad
Outdated
@@ -260,6 +260,16 @@ process exited normally and `[:error n]` otherwise. Example: `(process! | |||
(write-handle! (stderr!) prompt) | |||
(read-line-handle! (stdin!)))) | |||
|
|||
(def-rec prompt-non-empty! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be a very general function. Ideally the abstraction is something that takes a validator, an error message, and repeats the prompt until the validator passes.
validator/time-created | ||
validator/full-project])) | ||
|
||
(def edit-keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what this does, or have a more descriptive name?
@@ -118,6 +146,24 @@ | |||
"Comments\n" | |||
"--------\n\n" | |||
(pretty-comments cs))) | |||
'{:number n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very weird to me to have a single function that is supposed to know how to render every different item comment type. Why not different functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that items.rad needs some refactoring. In this case it is convenient to have the function pretty-item-view
handle distinguishing between the item types, otherwise there would be more matching where the function is used.
Did you have an idea of how to split it into different functions? I can only think of an option to pass flags to the functions of items and depending on that use specific functions, but I am not sure that will improve things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that flags are also not good (even in pretty-table-header
it looks bad).
I don't entirely understand the "more matching" problem. There'd be a function, pretty-issue
, that would call pretty-issue-header
, and so on. You don't need to match on the comment (unless you want to) if you already know at call-site what shape it'll have (which you will since you'll be calling from inside a function that knows the comment shape).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then you would still have to decide what function to call depending on the flag. So for example in list-items
for each of the following function you would have to match/decide which specific one to call: pretty-headline
, pretty-row
, pretty-table-header
. So would you have them refer to the specific functions depending on the flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for example in list-items for each of the following function you would have to match/decide which specific one to call: pretty-headline, pretty-row, pretty-table-header
I don't understand this. Can you explain?
Here's the rule. If I define a new machine, with it's own set of items, and I don't have write access to this repo, can I re-use any of the functionality? Clearly, right now the answer is "no". That means the abstractions are wrong. Maybe there is no common abstraction, but probably the answer is more of a middle ground: we can't have "do everything" functions such as pretty-item-view
, but we can have other functions that respect actual invariants. E.g.:
(def prompt-comment (fn [post] ...))
Which takes some string post
to put below the ---
, puts that and the line in a file, and sets you up in an editor, and gives you back the string that was inputed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. I think I am just not fully clear on which functions to abstract and which not, yet (fe list-items
) I think the general direction is clear, but I think it exceeds this PR as it would also change issue and patch code. I can write create an issue for the refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok (though in general I'm in favor of the refactor-what-you-touch philosophy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactoring issue: #665
For single-constructor Haskell data types: - `toRad` will skip the constructor, - `fromRad` will optionally parse the constructor. BREAKING CHANGE: This changes the format for key-pairs and signatures.
Transactor re-definition replaces eval re-difinition. This is a much simpler model. At first tx is set to the identity function, that is, the machine accepts all input expressions as is, and evaluates them. One can then redefine tx, to restrict the inputs to the machine. If tx throws an exception, then the input is not accepted, otherwise it can perform effects itself (e.g. mutate some refs), and then return an expression for evaluation on the machine. See https://github.com/radicle-dev/transparent-machines-doc for more information. BREAKING CHANGE: This totally changes how machines restrict their inputs, so is a major breaking change.
Non-hygienic first-class macros whose expanded code evaluates in a scope. BREAKING CHANGE: in particular changes `if` is now not a special-form and `test` is a macro which replaces `(:test ...)`.
BREAKING CHANGE: This changes the structure of the message that is signed before sending it to a machine. Machines set up before this commit will not accept the new signatures. `show-unbound` does not add formatting to the requests payload, to make signing request consistently to work also in other languages.
rad/prelude/io.rad
Outdated
@@ -260,6 +260,18 @@ process exited normally and `[:error n]` otherwise. Example: `(process! | |||
(write-handle! (stderr!) prompt) | |||
(read-line-handle! (stdin!)))) | |||
|
|||
(def-rec prompt-non-empty! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is now outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry for that!
rad/prelude/io.rad
Outdated
input does not pass the `validator`." | ||
(fn [prompt validator err-msg] | ||
(write-handle! (stderr!) prompt) | ||
(def input (read-line-handle! (stdin!))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just use prompt!
?
A registered project has
name
,description
,labels
&project-id
.Allowed commands are registering, editing, listing (and adding admins)
TODO change default machine name to server hosted one