Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Conversation

@fluffyemily
Copy link
Contributor

Emily Toop added 7 commits May 10, 2017 10:40
* Create tools directory containing new crate for mentat_cli.
* Add simple cli with mentat prompt.
* Open named database OR default to in memory database if no name provided

Rearrange workspace to allow import of mentat crate in cli crate

Create store object inside repl when started for connecting to mentat

Use provided DB name to open connection in store

Accept DB name as command line arg.

Open on CLI start

Implement '.open' command to open desired DB from inside CLI

* Implement Close command to close current DB.
* Closes existing open db and opens new in memory db

* Review comment: Use `combine` to parse arguments.

Move over to using Result rather than enums with err

* Accept and parse EDN Query and Transact commands (#453) (#465)

* Parse query and transact commands

* Implement is_complete for transactions and queries

* Improve query parser. Am still not happy with it though.

There must be some way that I can retain the eof() after the `then` that means I don't have to move the skip on spaces and eof

Make in process command storing clearer.

Add comments around in process commands.
Add alternative commands for transact/t and query/q

* Address review comments r=nalexander.

* Bump rust version number.
* Use `bail` when throwing errors.
* Improve edn parser.
* Remove references to unused `more` flag.
* Improve naming of query and transact commands.

* Send queries and transactions to mentat and output the results (#466)

* Send queries and transactions to mentat and output the results

move outputting query and transaction results out of store and into repl

* Add query and transact commands to help

* Execute queries and transacts passed in at startup

* Address review comments =nalexander.

* Bump rust version number.
* Use `bail` when throwing errors.
* Improve edn parser.
* Remove references to unused `more` flag.
* Improve naming of query and transact commands.

* Execute command line args in order

* Addressing rebase issues
* Implement exit command for cli tool

* Address review comments r=rnewman

* Include exit commands in help
@fluffyemily fluffyemily self-assigned this Jun 29, 2017
@fluffyemily fluffyemily requested a review from rnewman June 29, 2017 20:36
edn::Value::Vector((&schema.schema_map).iter()
.filter_map(|(entid, attribute)| {
if let Some(ident) = schema.get_ident(*entid) {
if !ident.namespace.starts_with("db") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we want an is_builtin predicate instead of doing this.

A more thorough approach is to check whether the entid of the ident is in the db part or the user part, no?

return Some(attribute.to_edn_value(Some(ident.clone())));
}
}
return None;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Equivalent to just

    None


edn::Value::Vector((&schema.schema_map).iter()
.filter_map(|(entid, attribute)| {
if let Some(ident) = schema.get_ident(*entid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

One advantage of match:

match schema.get_ident(*entid) {
    Some(ident) if ident.is_builtin() => {
        Some(attribute.to_edn_value(Some(ident.clone())))
    },
    _ => None,
}

@fluffyemily fluffyemily force-pushed the fluffyemily/cli branch 2 times, most recently from c08a14d to 2b6398b Compare November 21, 2017 16:33
@rnewman
Copy link
Collaborator

rnewman commented Apr 25, 2018

@fluffyemily is there anything to salvage from this PR?

@sc13-bioinf
Copy link
Contributor

It would be great to have an edn dump of the current schema available in the android API. I am happy to try and make a PR for that. I guess that you have some code to convert the output of current_schema to edn in the PR?

@rnewman
Copy link
Collaborator

rnewman commented Aug 27, 2018

@sc13-bioinf: Conn.current_schema().to_edn_value() does what you want.

@sc13-bioinf
Copy link
Contributor

Is there a way to convert that into something similar to the contents of cities.edn?
I seem to get something like:

Keyword(Keyword(NamespaceableName { namespace: Some("db"), name: "ident" })): Keyword(Keyword(NamespaceableName { namespace: Some("community"), name: "name" }))

@rnewman
Copy link
Collaborator

rnewman commented Aug 27, 2018

@sc13-bioinf you can use to_pretty to get a pretty-printed string, and edn::Value implements Display, so you can just use it directly in a formatter or call to_string on it to get a compact representation.

@sc13-bioinf
Copy link
Contributor

I had a go at adding this to the Android bindings. Not sure how correct / safe this is as I am new to rust + JNA.

master...sc13-bioinf:android-current-schema

If you approve then I can submit a PR or make some changes.

@rnewman
Copy link
Collaborator

rnewman commented Aug 29, 2018

@sc13-bioinf you should submit a PR, rather than trying to have folks discuss it here. Thanks!

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.

4 participants