38 pressing tab helps in finding gamecommands #39
Merged@github-juk3n wants to merge
38-pressing-tab-helps-in-finding-gamecommands into mainMerged as
657bc97e7a6d.3 files changed
modified
README.md +11 -0 | @@ -31,5 +31,16 @@ user:~/some/path$ fluffy rm game_name | ||
| 31 | 31 | ## Installation |
| 32 | 32 | |
| 33 | 33 | - Move fluffy to the target folder (after the first run it will create an sql file) |
| 34 | +- (optional) Add fluffy to PATH in .bashrc file | |
| 35 | +```console | |
| 36 | +export PATH=$PATH:/path/to/target/folder/fluffy | |
| 37 | +``` | |
| 34 | 38 | - Downloaded file is ready to use |
| 35 | 39 | |
| 40 | +### Auto-completion (optional) | |
| 41 | + | |
| 42 | +- Move fluffy-completion.bash script to target folder | |
| 43 | +- Add below line to .bashrc file | |
| 44 | +```console | |
| 45 | +source /path/to/target/folder/fluffy-completion.bash | |
| 46 | +``` | |
| @@ -31,5 +31,16 @@ user:~/some/path$ fluffy rm game_name | |||
| 31 | ## Installation | 31 | ## Installation |
| 32 | 32 | ||
| 33 | - Move fluffy to the target folder (after the first run it will create an sql file) | 33 | - Move fluffy to the target folder (after the first run it will create an sql file) |
| 34 | +- (optional) Add fluffy to PATH in .bashrc file | ||
| 35 | +```console | ||
| 36 | +export PATH=$PATH:/path/to/target/folder/fluffy | ||
| 37 | +``` | ||
| 34 | - Downloaded file is ready to use | 38 | - Downloaded file is ready to use |
| 35 | 39 | ||
| 40 | +### Auto-completion (optional) | ||
| 41 | + | ||
| 42 | +- Move fluffy-completion.bash script to target folder | ||
| 43 | +- Add below line to .bashrc file | ||
| 44 | +```console | ||
| 45 | +source /path/to/target/folder/fluffy-completion.bash | ||
| 46 | +``` | ||
modified
app/src/fluffyApplication.cpp +6 -1 | @@ -13,7 +13,12 @@ auto FluffyApplication::handleCommand( | ||
| 13 | 13 | ) -> void { |
| 14 | 14 | if (command == "show") { |
| 15 | 15 | for (auto &game : gameRepository->getGames()) { |
| 16 | - std::cout << game.getName() << ": " << game.getPath() << std::endl; | |
| 16 | + std::cout << game.getName() << ": " << game.getPath() << std::endl; | |
| 17 | + } | |
| 18 | + } | |
| 19 | + else if (command == "only-games") { | |
| 20 | + for (auto &game : gameRepository->getGames()) { | |
| 21 | + std::cout << game.getName() << std::endl; | |
| 17 | 22 | } |
| 18 | 23 | } |
| 19 | 24 | else if (command == "rm") { |
| @@ -13,7 +13,12 @@ auto FluffyApplication::handleCommand( | |||
| 13 | ) -> void { | 13 | ) -> void { |
| 14 | if (command == "show") { | 14 | if (command == "show") { |
| 15 | for (auto &game : gameRepository->getGames()) { | 15 | for (auto &game : gameRepository->getGames()) { |
| 16 | - std::cout << game.getName() << ": " << game.getPath() << std::endl; | 16 | + std::cout << game.getName() << ": " << game.getPath() << std::endl; |
| 17 | + } | ||
| 18 | + } | ||
| 19 | + else if (command == "only-games") { | ||
| 20 | + for (auto &game : gameRepository->getGames()) { | ||
| 21 | + std::cout << game.getName() << std::endl; | ||
| 17 | } | 22 | } |
| 18 | } | 23 | } |
| 19 | else if (command == "rm") { | 24 | else if (command == "rm") { |
added
fluffy-completion.bash +17 -0 | new file mode 100644 | ||
| @@ -0,0 +1,17 @@ | ||
| 1 | +_fluffy_complete() { | |
| 2 | + local local cur prev opts | |
| 3 | + COMREPLY=() | |
| 4 | + cur="${COMP_WORDS[COMP_CWORD]}" | |
| 5 | + prev="${COMP_WORDS[COMP_CWORD-1]}" | |
| 6 | + | |
| 7 | + if [[ "$prev" == "fluffy" ]]; then | |
| 8 | + local comms="play show add" | |
| 9 | + COMPREPLY=( $(compgen -W "${comms}" -- "${cur}") ) | |
| 10 | + fi | |
| 11 | + | |
| 12 | + if [[ "$prev" == "play" ]]; then | |
| 13 | + local games=$(fluffy only-games) | |
| 14 | + COMPREPLY=( $(compgen -W "${games}" -- "${cur}") ) | |
| 15 | + fi | |
| 16 | +} | |
| 17 | +complete -F _fluffy_complete fluffy | |
| new file mode 100644 | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | +_fluffy_complete() { | ||
| 2 | + local local cur prev opts | ||
| 3 | + COMREPLY=() | ||
| 4 | + cur="${COMP_WORDS[COMP_CWORD]}" | ||
| 5 | + prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
| 6 | + | ||
| 7 | + if [[ "$prev" == "fluffy" ]]; then | ||
| 8 | + local comms="play show add" | ||
| 9 | + COMPREPLY=( $(compgen -W "${comms}" -- "${cur}") ) | ||
| 10 | + fi | ||
| 11 | + | ||
| 12 | + if [[ "$prev" == "play" ]]; then | ||
| 13 | + local games=$(fluffy only-games) | ||
| 14 | + COMPREPLY=( $(compgen -W "${games}" -- "${cur}") ) | ||
| 15 | + fi | ||
| 16 | +} | ||
| 17 | +complete -F _fluffy_complete fluffy | ||