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 commented Jan 22, 2017

This is climate if anyone is wondering :)

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

@moverest moverest Jan 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need return $status.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want a local variable here: setset -l

return $status
end

function __fish_climate_already_has_argument
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the function to __fish_climate_has_no_argument.

@Hunsu Hunsu force-pushed the climate branch 2 times, most recently from 72b79ed to a501aac Compare January 23, 2017 17:48
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 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.

@@ -0,0 +1,3 @@
function __fish_is_git_repository --discription 'Check if current directory is a git repository'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed the typo but still not loading.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@krader1961
Copy link
Contributor

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
Development

Successfully merging this pull request may close these issues.

None yet

5 participants