Skip to content

Autocomplete for occ app commands - #1476

Merged
MorrisJobke merged 8 commits into
masterfrom
autocomplete-for-occ-app-commands
Sep 29, 2016
Merged

Autocomplete for occ app commands#1476
MorrisJobke merged 8 commits into
masterfrom
autocomplete-for-occ-app-commands

Conversation

@nickvergessen

@nickvergessennickvergessen commented Sep 20, 2016

Copy link
Copy Markdown
Member
# 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

@nickvergessennickvergessen added this to the Nextcloud 11.0 milestone Sep 20, 2016
@mention-bot

Copy link
Copy Markdown

@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
nickvergessenforce-pushed the autocomplete-for-occ-app-commands branch from c618fc5 to 9695cfeCompareSeptember 21, 2016 12:43
@LukasReschke

LukasReschke commented Sep 26, 2016

Copy link
Copy Markdown
Member

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

@LukasReschke

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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

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

@LukasReschke
LukasReschkeforce-pushed the autocomplete-for-occ-app-commands branch from e31f5d5 to 0facad2CompareSeptember 26, 2016 11:51
@LukasReschke

Copy link
Copy Markdown
Member

Works nicely, I commited regenerated autoloading files 👍

@nickvergessen
nickvergessenforce-pushed the autocomplete-for-occ-app-commands branch from 0facad2 to 64570d6CompareSeptember 26, 2016 11:52
@MorrisJobke

MorrisJobke commented Sep 28, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
MorrisJobkeforce-pushed the autocomplete-for-occ-app-commands branch from f88c9eb to 6188955CompareSeptember 29, 2016 13:57
@MorrisJobke

Copy link
Copy Markdown
Member

Rebased to fix the sign-off check issue

@MorrisJobke

Copy link
Copy Markdown
Member

Tested and works now 👍

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

@MorrisJobkeMorrisJobke 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
Copy Markdown

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 CoverageFile 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%newcore/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
Copy Markdown
MemberAuthor

@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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to releaseReady to be released and/or waiting for tests to finishenhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@nickvergessen@mention-bot@LukasReschke@MorrisJobke@codecov-io