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

Rad registry #652

Open
wants to merge 16 commits into
base: v2.0.0
Choose a base branch
from
Open

Rad registry #652

wants to merge 16 commits into from

Conversation

MeBrei
Copy link
Contributor

@MeBrei MeBrei commented May 31, 2019

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

@MeBrei MeBrei changed the base branch from master to v2 May 31, 2019 10:14
@MeBrei MeBrei marked this pull request as ready for review June 5, 2019 08:26
@MeBrei MeBrei requested review from jameshaydon and jkarni June 5, 2019 08:38
bin/rad-registry Outdated

;; TODO Replace with server hosted machine
(def default-machine-name
"The default registry machine."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a function?

Copy link
Contributor Author

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"])
Copy link
Contributor

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?

Copy link
Contributor Author

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"])
Copy link
Contributor

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>
Copy link
Contributor

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})
Copy link
Contributor

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?

@@ -82,11 +82,11 @@

(def uppercase-item
(fn [item]
(lookup item {:issue "Issue" :patch "Patch"})))
(lookup item {:issue "Issue" :patch "Patch" :project "Project"})))
Copy link
Contributor

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

Copy link
Contributor Author

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.

@@ -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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Same as `prompt!`, but repeats id the input empty."
"Same as `prompt!`, but repeats if the input is empty."

@@ -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!
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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).

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@jkarni jkarni Jun 6, 2019

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring issue: #665

jameshaydon and others added 13 commits June 5, 2019 15:25
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.
@MeBrei MeBrei changed the base branch from v2 to v2.0.0 June 6, 2019 12:37
@@ -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!
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry for that!

input does not pass the `validator`."
(fn [prompt validator err-msg]
(write-handle! (stderr!) prompt)
(def input (read-line-handle! (stdin!)))
Copy link
Contributor

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!?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants