Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore whitespace. press enter with no input or input ended by whitespace #115

Closed
wants to merge 9 commits into from

Conversation

tzzed
Copy link
Contributor

@tzzed tzzed commented Jul 9, 2020

this a fix of #106

genji> <press return, with or without whitespace>
genji> 

and

genji> create table foo; <press return with whitespace after the ; >
... <press ';', then return>
genji>

both are fixed.

Copy link
Collaborator

@asdine asdine left a comment

Choose a reason for hiding this comment

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

Thank you @tzzed!

I have proposed a simpler alternative in the comments

.gitignore Outdated
@@ -22,3 +22,6 @@ profile.*

# Databases
*.db
*.idea
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should not be added to this PR by rather to your global .gitignore. Read this to see how to do it https://sebastiandedeyne.com/setting-up-a-global-gitignore-file/

//If we press enter without any query
case len(in) == 0:
return sh.QueryError(in)
// If it ends by espace "; "
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check is not necessary if we trim in

@@ -184,6 +184,16 @@ func (sh *Shell) execute(in string) {
}
}

// Query Error return an error if we press return with no input, or ended by whitespace
func (sh *Shell) QueryError(in string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name of this function doesn't seem to have anything to do with the content of the function, does it?

@tzzed tzzed changed the title ignore whitespace. press enter with no input, ended by whitespace ignore whitespace. press enter with no input or input ended by whitespace Jul 9, 2020
tzzed added a commit to tzzed/genji that referenced this pull request Jul 10, 2020
@tzzed
Copy link
Contributor Author

tzzed commented Jul 10, 2020

implementation of @asdine's suggestion for a simpler version.

Copy link
Collaborator

@asdine asdine left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍
@tzzed Could you remove the .gitignore lines and rebase your PR please?

@asdine
Copy link
Collaborator

asdine commented Jul 12, 2020

@tzzed I can't merge your PR, you need to rebase it

@tzzed tzzed closed this Jul 12, 2020
@tzzed tzzed deleted the InputShell branch July 12, 2020 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants