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

Add completion for climate #3760

Closed
wants to merge 1 commit into from
Closed

Add completion for climate #3760

wants to merge 1 commit into from

Conversation

@Hunsu
Copy link
Contributor

@Hunsu Hunsu commented Jan 22, 2017

No description provided.

@adtac
Copy link

@adtac adtac commented Jan 22, 2017

This is climate if anyone is wondering :)

@@ -0,0 +1,82 @@
# fish completion for climate

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

This comment is useless. You should probably write a short description of the tool with a link to the project's man page (or github) instead.

This comment has been minimized.

@faho

faho Jan 24, 2017
Member

Yeah. While you're at it, ditch the first line. The rest is okay, and I appreciate the link!

# Meta
complete -f -n '__fish_climate_already_has_argument' -c climate -a help -d 'Show help'
complete -f -n '__fish_climate_already_has_argument' -c climate -a update -d 'Update your climate install'
complete -f -n '__fish_climate_already_has_argument' -c climate -a uninstall -d 'uninstall your climate installi'

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

Typo: uninstall your climate installiUninstall your climate install.

Maybe use something shorter like Uninstall climate.

complete -f -n '__fish_climate_already_has_argument' -c climate -a download-dir -d 'Download dir from server'
complete -n '__fish_climate_already_has_argument' -c climate -a upload -d 'Upload to server'
complete -f -n '__fish_climate_already_has_argument' -c climate -a ssh-mount -d 'Mount a remote path'
complete -n '__fish_climate_already_has_argument' -c climate -a ssh-unmount -d 'nmount a ssh mount'

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

Unmount a ssh mount?

complete -f -c climate -n '__fish_is_git_repository and __fish_climate_already_has_argument' -a user-stats -d 'Calculate total contribution for a user'

# Performance
complete -f -n '__fish_climate_already_has_argument' -c climate -a overview -d 'Display an performance overviewj'

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

Display an performance overviewjDisplay a performance overview?

# Network
complete -f -n '__fish_climate_already_has_argument' -c climate -a speedtest -d 'Test your network speed'
complete -f -n '__fish_climate_already_has_argument' -c climate -a local-ip -d 'Retrieve your local ip address'
complete -f -n '__fish_climate_already_has_argument' -c climate -a is-online -d 'Verify if you''re online'

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

'Verify if you''re online''Verify if you\'re online'

> echo 'Verify if you''re online'
'Verify if youre online'

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

Here, fish concatenates the two strings. It's useful when you want to expand variables:

> set var 'Hi there!'
> echo 'Did you say "'$var'"?'
Did you say "Hi there!"?

It works like a charm with lists as well:

> set var 'Hi there!' 'Hello world!'
> echo 'Did you say "'$var'"?'
Did you say "Hi there!"? Did you say "Hello world!"?

function __fish_is_git_repository
git rev-parse --is-inside-work-tree ^/dev/null >/dev/null
return $status

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

You don't need return $status.


function __fish_climate_already_has_argument
set cmd (commandline -opc)
if not set -q cmd[2]

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

You don't need the if statement with the returns.

Just write: not set -q cmd[2]

end

function __fish_climate_already_has_argument
set cmd (commandline -opc)

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

You want a local variable here: setset -l

return $status
end

function __fish_climate_already_has_argument

This comment has been minimized.

@moverest

moverest Jan 22, 2017
Contributor

I'm a bit confused by what this function is supposed to do given its name.

__fish_climate_already_has_argument implies that it should return 0 (true) if the command line has an argument but it clearly does the exact opposite. Have I missed something?

This comment has been minimized.

@Hunsu

Hunsu Jan 23, 2017
Author Contributor

I renamed the function to __fish_climate_has_no_argument.

@Hunsu Hunsu force-pushed the Hunsu:climate branch 2 times, most recently from 72b79ed to a501aac Jan 23, 2017
complete -n '__fish_climate_has_no_argument' -c climate -a ssh-unmount -d 'Unmount a ssh mount'

# git
complete -f -c climate -n '__fish_is_git_repository and __fish_climate_has_no_argument' -a undo-commit -d 'Undo the latest commit'

This comment has been minimized.

@faho

faho Jan 24, 2017
Member

This doesn't work because of a missing ";" - __fish_is_git_repository; and. The way it is now, __fish_is_git_repository gets the rest as argument, and __fish_climate_has_no_argument is never executed.

# but complex combination of Linux commands.
# The tool can be found at https://github.com/adtac/climate

function __fish_is_git_repository

This comment has been minimized.

@faho

faho Jan 24, 2017
Member

This might be useful elsewhere, so it should probably be extracted into its own function file. Not a priority though.

This comment has been minimized.

@moverest

moverest Jan 24, 2017
Contributor

It's already implemented in git.fish. Maybe split it?

This comment has been minimized.

@faho

faho Jan 25, 2017
Member

That one prints the working directory, though completion conditions are implicitly silenced.

Yeah, we should extract it. I can do that later though.

This comment has been minimized.

@Hunsu

Hunsu Feb 5, 2017
Author Contributor

I added __fish_is_git_repository.fish into share/functions folder (also into /usr/share/fish/functions, .config/fish/functions) and I get __fish_is_git_repository: command not found

@@ -0,0 +1,82 @@
# fish completion for climate

This comment has been minimized.

@faho

faho Jan 24, 2017
Member

Yeah. While you're at it, ditch the first line. The rest is okay, and I appreciate the link!

@faho faho added this to the next-minor milestone Jan 24, 2017
@faho
Copy link
Member

@faho faho commented Jan 24, 2017

The failing tests here are a result of bad timing - this is based on a broken master. Nothing to worry about here.

@Hunsu Hunsu force-pushed the Hunsu:climate branch from a501aac to a29e4ba Feb 5, 2017
@@ -0,0 +1,3 @@
function __fish_is_git_repository --discription 'Check if current directory is a git repository'

This comment has been minimized.

@moverest

moverest Feb 5, 2017
Contributor

You've made a typo, that's why it's not loading: --description.

This comment has been minimized.

@Hunsu

Hunsu Feb 5, 2017
Author Contributor

fixed the typo but still not loading.

This comment has been minimized.

@moverest

moverest Feb 5, 2017
Contributor

That's strange... it works with me.

Have you tried to do a source path/to/__fish_is_git_repository.fish? Did you put it in ~/.config/fish/functions with the typo fixed to test it?

This comment has been minimized.

@Hunsu

Hunsu Feb 5, 2017
Author Contributor

Now it works after I did source /usr/share/fish/functions/__fish_is_git_repository.fish. Perhaps /usr/share/fish/functions/is only sourced at login ?

This comment has been minimized.

@moverest

moverest Feb 5, 2017
Contributor

It's loaded when you request it for the first time. It sources the first __fish_is_git_repository.fish it finds the directories listed in fish_function_path.

> echo $fish_function_path 
/home/clement/.config/fish/functions /etc/fish/functions /usr/share/fish/vendor_functions.d /usr/share/fish/functions

My guess is that you have a file named __fish_is_git_repository.fish without the correction in one of the directories listed before /usr/share/fish/functions.

@Hunsu Hunsu force-pushed the Hunsu:climate branch from a29e4ba to 20c256c Feb 5, 2017
@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Feb 6, 2017

Thx. Merged as a5e8b81.

@krader1961 krader1961 closed this Feb 6, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.