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

Show schema of current DB#487

Merged
fluffyemily merged 1 commit intofluffyemily/clifrom
fluffyemily/schema
Jun 23, 2017
Merged

Show schema of current DB#487
fluffyemily merged 1 commit intofluffyemily/clifrom
fluffyemily/schema

Conversation

@fluffyemily
Copy link
Copy Markdown
Contributor

Ok(Command::Close)
});

let schema_parser = string(SCHEMA_COMMAND)
Copy link
Copy Markdown
Contributor Author

@fluffyemily fluffyemily Jun 22, 2017

Choose a reason for hiding this comment

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

I tried to generalise no_arg_parser to take a command as an arg and then use that to determine how the command was parsed, but I couldn't get the lifetimes right. I think that was due to CLOSE_COMMAND, SCHEMA_COMMAND and EXIT_COMMAND all being static strings, which I then also couldn't use in a match. I think there is probably some way to get around it that I just haven't figured out yet. Need to spend some more time with the rust book. Will file a follow up bug for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this might be an unnecessary rabbit hole.

Take a look at https://docs.rs/combine/2.3.2/combine/fn.not_followed_by.html instead?

@fluffyemily fluffyemily removed the request for review from jaredhirsch June 22, 2017 12:15
Ok(Command::Close)
});

let schema_parser = string(SCHEMA_COMMAND)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this might be an unnecessary rabbit hole.

Take a look at https://docs.rs/combine/2.3.2/combine/fn.not_followed_by.html instead?

fn test_exit_parser_with_args() {
let input = ".exit arg1";
let err = command(&input).expect_err("Expected an error");
let input = ".exit arg1";let err = command(&input).expect_err("Expected an error");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Put that newline back!

Command::Query(query) => self.execute_query(query),
Command::Schema => {
let edn = self.store.fetch_schema();
println!("{}", edn.to_pretty(120).unwrap());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use expect instead of unwrap — or, better, handle the error!

@fluffyemily fluffyemily merged commit a9c05ba into fluffyemily/cli Jun 23, 2017
@fluffyemily fluffyemily deleted the fluffyemily/schema branch June 23, 2017 14:03
fluffyemily pushed a commit that referenced this pull request Nov 21, 2017
fluffyemily pushed a commit that referenced this pull request Nov 21, 2017
fluffyemily pushed a commit that referenced this pull request Nov 21, 2017
* Create mentat command line.
* Create tools directory containing new crate for mentat_cli.
* Add simple cli with mentat prompt.

* Remove rustc-serialize dependency

* Open DB inside CLI (#452) (#463)

* 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

* Exit CLI (#457) (#484) r-rnewman

* Implement exit command for cli tool

* Address review comments r=rnewman

* Include exit commands in help

* Show schema of current DB (#487)

* Fixing rebase issues

* addressing nit

* Match updated dependencies on CLI crate and remove unused import
RDR8 pushed a commit to RDR8/mentat that referenced this pull request Mar 12, 2018
* Create mentat command line.
* Create tools directory containing new crate for mentat_cli.
* Add simple cli with mentat prompt.

* Remove rustc-serialize dependency

* Open DB inside CLI (mozilla#452) (mozilla#463)

* 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 (mozilla#453) (mozilla#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 (mozilla#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

* Exit CLI (mozilla#457) (mozilla#484) r-rnewman

* Implement exit command for cli tool

* Address review comments r=rnewman

* Include exit commands in help

* Show schema of current DB (mozilla#487)

* Fixing rebase issues

* addressing nit

* Match updated dependencies on CLI crate and remove unused import
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.

2 participants