Open julrich opened 3 years ago
It might be a problem, awk
is a good tool try here!
Found this for reading .ini
-files in zsh: https://github.com/zdharma/zsh-string-lib/blob/master/%40str-read-ini
Another aspect: It needs to regexp-match against the array of regexps given in projectmap
:
https://github.com/wakatime/wakatime#configuring
https://github.com/wakatime/komodo-wakatime/blob/master/components/wakatime/projects/projectmap.py#L2-L21
Might suck to handle / escape those regexps given as keys in .wakatime.cfg
, too :/.
At least that's how it's working for the other IDE-plugins so far.
So all in all, a bit more involved. But would be really nice to have :).
Can we parse it via wakatime
CLI somehow?
Huh, that might work. Haven't look at the CLI options admittedly. Could look around how others are doing this in other plugins, too! Will try my hands on this in the next days!
Looks like that may even be the default behavior, if the folder is not explicitly given to the CLI?
--project PROJECT optional project name
--alternate-project ALTERNATE_PROJECT
optional alternate project name; auto-discovered
project takes priority
from: https://wakatime.com/help/creating-plugin#sending-file-to-wakatime-cli:executing-background-process
So possibly this part is duplicating default behaviour of the CLI? https://github.com/sobolevn/wakatime-zsh-plugin/blob/master/wakatime.plugin.zsh#L31-L38
But I'm not sure if that behavior is restricted to entity-type
file
. Which would mean altering the plugin even further... would probably have to send the current path as file
, with entity-type
set to file
. That should then enable the "default" detection described here:
https://wakatime.com/faq#rename-projects (re: one of four ways
)
Any idea if that would have other, unintended consequences? Like in the way logged time is displayed inside the wakatime dashboard?
Looks like that may even be the default behavior, if the folder is not explicitly given to the CLI?
That's correct, but you'll need to use --alternate-project
instead of --project
in your clone of this zsh plugin. You will also need the new Go wakatime-cli since Python had a bug around alternate project that might cause it to be used instead of the auto-detected project.
Could we also add a check for a .wakatime-project
file to get the project name? Based on get_project_info
in wakatime
and WithDetection
in wakatime-cli
, it takes precedence over the git folder name:
First looks for a .wakatime-project file. Second, uses the --project arg. Third, uses the folder name from a revision control repository. Last, uses the --alternate-project arg.
It's definitely much easier to parse than projectmap
too: the first line is the project name, the optional second line is the branch name. If the branch name isn't in the file, it will try to get it from rev control (while still using the project name from the file).
Thanks!
EDIT: I submitted PR #13 to add support for the .wakatime-project
file ππ»
PRs are welcome π
Would expect the wakatime-cli
to also respect .wakatime-project
-files, right?
Will try my hand on a PR if I get the time, but can't promise anything right now!
@sobolevn I'd love to help! Time to reach into that tiny corner of my brain where I stuff my shell script knowledge π
Would expect the
wakatime-cli
to also respect.wakatime-project
-files, right? Will try my hand on a PR if I get the time, but can't promise anything right now!
@julrich yep it does check it first. Those two links in my last comment are where wakatime
and wakatime-cli
check for a .wakatime-project
file (it's the first check so it has #1 priority):
Would be really nice, if the plugin could read the
projectmap
defined in.wakatime.cfg
. Could fall back / use the existing behaviour, if that doesn't exist.As all the other IDEs I'm using (vim, VS Code, PHPStorm) already respect that entry, which results in consistent projects in wakatime, it would be really nice to match that. Because git repositories don't necessarily map to projects in a 1:1 manner.
Would be open to trying my hands on a PR, just not sure how fast I'd be... as I'm not really knowledgeable in zsh scripting.