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

Autocomplete for occ app commands #1476

Merged
merged 8 commits into from
Sep 29, 2016

Conversation

nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Sep 20, 2016

# BASH ~4.x, ZSH
source <([program] _completion --generate-hook)

# BASH ~3.x, ZSH
[program] _completion --generate-hook | source /dev/stdin

# BASH (any version)
eval $([program] _completion --generate-hook)

And enjoy full autocompelete for everything on the app:* commands (app names, group ids, etc.)

Todo

  • app:*
  • config:*
  • db:*
  • l10n:*
  • log:*
  • security:*
  • twofactorauth:*

For another PR to keep it simple

  • encryption:*
  • group:*
  • integrity:*
  • maintenance:*
  • user:*

@MorrisJobke @LukasReschke @ChristophWurst

@nickvergessen nickvergessen added this to the Nextcloud 11.0 milestone Sep 20, 2016
@mention-bot
Copy link

@nickvergessen, thanks for your PR! By analyzing the annotation information on this pull request, we identified @icewind1991, @MorrisJobke and @Xenopathic to be potential reviewers

@nickvergessen nickvergessen force-pushed the autocomplete-for-occ-app-commands branch from c618fc5 to 9695cfe Compare September 21, 2016 12:43
@LukasReschke
Copy link
Member

LukasReschke commented Sep 26, 2016

Merged nextcloud/3rdparty#16 and updated third-party reference to nextcloud/3rdparty@cc365d1

@LukasReschke
Copy link
Member

@nickvergessen So what command do I have to execute exactly? All those three you posted don't work locally here. I guess I miss something obvious ;)

@nickvergessen
Copy link
Member Author

For me I execute eval $(/var/www/nextcloud/occ _completion --generate-hook)

Afterwards /var/www/nextcloud/occ main<tab> autocompletes maintenance:

@LukasReschke LukasReschke force-pushed the autocomplete-for-occ-app-commands branch from e31f5d5 to 0facad2 Compare September 26, 2016 11:51
@LukasReschke
Copy link
Member

Works nicely, I commited regenerated autoloading files 👍

@nickvergessen nickvergessen force-pushed the autocomplete-for-occ-app-commands branch from 0facad2 to 64570d6 Compare September 26, 2016 11:52
@MorrisJobke
Copy link
Member

MorrisJobke commented Sep 28, 2016

I get this in my zsh (while trying the autocomplete):

$ occ <tab>

  [RuntimeException]                                                               
  Failed to configure from environment; Environment var CMDLINE_CONTENTS not set.  


_completion [-g|--generate-hook] [-p|--program PROGRAM] [-m|--multiple] [--shell-type [SHELL-TYPE]]


_occ_48ee92c85c317686_complete:local: not valid in this context: -x


  [RuntimeException]                                                               
  Failed to configure from environment; Environment var CMDLINE_CONTENTS not set.  


_completion [-g|--generate-hook] [-p|--program PROGRAM] [-m|--multiple] [--shell-type [SHELL-TYPE]]

_occ_48ee92c85c317686_complete:local: not valid in this context: -x


  [RuntimeException]                                                               
  Failed to configure from environment; Environment var CMDLINE_CONTENTS not set.  


_completion [-g|--generate-hook] [-p|--program PROGRAM] [-m|--multiple] [--shell-type [SHELL-TYPE]]

_occ_48ee92c85c317686_complete:local: not valid in this context: -x

And this in my bash (4.x) (already for sourcing the shell completion)

[mjob@wigrid server]$ eval $(./occ _completion --generate-hook)
bash: Syntaxfehler beim unerwarteten Wort `('
[mjob@wigrid server]$ source <(./occ _completion --generate-hook)
bash: compdef: Kommando nicht gefunden.

@nickvergessen
Copy link
Member Author

I got a similar error just now, because an app required an update.
Will have a look if we can add better error handling there...

@nickvergessen
Copy link
Member Author

Fixed the issue @MorrisJobke

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@MorrisJobke MorrisJobke force-pushed the autocomplete-for-occ-app-commands branch from f88c9eb to 6188955 Compare September 29, 2016 13:57
@MorrisJobke
Copy link
Member

Rebased to fix the sign-off check issue

@MorrisJobke
Copy link
Member

Tested and works now 👍

Sadly it only work for full path (/path/to/occ) and not for relative path (./occ)

@MorrisJobke MorrisJobke added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Sep 29, 2016
@codecov-io
Copy link

Current coverage is 30.59% (diff: 0.00%)

Merging #1476 into master will decrease coverage by 0.08%

@@             master      #1476   diff @@
==========================================
  Files          1080       1082     +2   
  Lines         59885      60059   +174   
  Methods        6775       6810    +35   
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          18375      18375          
- Misses        41510      41684   +174   
  Partials          0          0          

Sunburst

Diff Coverage File Path
0% core/Command/App/CheckCode.php
0% core/Command/TwoFactorAuth/Disable.php
0% core/Command/App/ListApps.php
0% core/Command/Log/File.php
0% new core/Command/Config/App/Base.php
0% core/register_command.php
0% core/Command/App/Disable.php
0% core/Command/TwoFactorAuth/Enable.php
0% lib/private/Console/Application.php
0% core/Command/L10n/CreateJs.php

Review all 27 files changed

Powered by Codecov. Last update 8a14f4a...6188955

@nickvergessen
Copy link
Member Author

@MorrisJobke works for relative paths here as well. I guess you just need to generate it twice:

eval $(/var/www/nextcloud/occ _completion --generate-hook)
eval $(./occ _completion --generate-hook)

Just tested and confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants