Comments (3)
I've taken the above mentioned approach and reduced the clutter in the completer.py
module. There is now a parser.py
(complementing a lexer.py
) that reads the entire command set into a tree rooted at kubectl
. Given a command line, we walk the nodes of this tree as far as we can and return the children of the last node in the path as suggestions to fuzzyfinder.
TODO:
- finish the global options parsing at any level of the subcommand
- complete the
get_resource(..)
calls given a localFlag is used.
from kube-shell.
Ran into a bunch of troubles doing this. My initial idea was to read the command tree into a nested set of parsers created using argparse. However, argparse is not tolerant if parts of the command line don't adhere to the command tree it holds. It does a hard os.exit()
which is problematic.
Going to switch back to a simple object tree representation. We will walk the tree and identify the extent of the traversal until tokens on command line are identified. The children of the node we reach point to the list of possible suggestions.
// CommandTree represents the Node (command) and its children (subcommands/options)
type CommandTree struct {
Node string,
Children []CommandTree
}
func Walk(t *CommandTree, parsed []string, unparsed []string) (suggestions []string) {
token = unparsed.Pop() // get first token
if t.Node == token {
parsed = append(parsed, token)
for _, child := range(t.Children) {
// walk all children with rest of the tokens
Walk(child, parsed, unparsed)
}
} else {
if len(unparsed) > 0 {
suggestions := make([]string)
for _, suggestion := range(t.Children) {
suggestions = append(suggestions, suggestion)
}
return // suggestions come from children
}
}
}
from kube-shell.
In case any one wants try out please check this branch
from kube-shell.
Related Issues (20)
- [UX] YAML syntax highlight?
- Error when input backslash : No escaped character
- how can I switch multiple clusters? HOT 2
- Standard install broken on debian stretch
- Best way to collaborate?
- Server-side autocomplete doesn't work on kubernetes object names with Ubuntu 18.10 HOT 2
- Unable to use kube-shell in wsl (alpine)
- Python 3.7 support (fix deprecated yaml call) HOT 3
- Kube-shell for Windows is not passing input text to kubectl HOT 1
- on startup on RHEL 7.6 notebook get load errors
- [INFORMATION SHARE] A web based kubectl tool.
- Fix simple typo: recieve -> receive
- Execution error HOT 1
- rename-context missing from completion
- command not found: kubeshell HOT 3
- Autosuggestion isn't working on List of available pods HOT 1
- Warning while loading Kube-shell HOT 4
- Customize shell prompt
- Command not found HOT 2
- F5 button not able to change namespace
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kube-shell.