go-calendar

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 8 Imported by: 0

README

go-calendar

Generate a calendar from a JSON file.

Example

Options with args

Option Description Default
-k KEY Key of the date date
-c KEY Key of the counter
-d First day of the week 1 (Monday)
-i FILE Path to the JSON file data.json
-o FILE Path to the output file out.svg
-q Quiet mode false
-h Hexa color (alpha is optionnal) 00C8C8FF

Usage

There are differents possible usages depending on your JSON file.

JSON file with dates
[
  {
    "date": "2022-11-06",
  },
  {
    "date": "2022-11-07",
  },
]

You will need to specify the key of the date and the key of the counter

go run github.com/Its-Just-Nans/go-calendar -k date
JSON file with a counter
[
  {
    "date": "2022-11-06",
    "num": 9
  },
  {
    "date": "2022-11-06",
    "num": 1
  },
]

You will need to specify the key of the date and the key of the counter

go run github.com/Its-Just-Nans/go-calendar -k date -c num

Example

Generate calendar from Github contributions

Using gh api and jq, you can get your contributions from Github with

gh api graphql -F owner='Its-Just-Nans' -f query='
    query( $owner: String!) {
      user(login: $owner) {
    contributionsCollection {
      contributionCalendar {
        totalContributions
        weeks {
          contributionDays {
            contributionCount
            weekday
            date
          }
        }
      }
    }
  }}' | jq '[.data.user.contributionsCollection.contributionCalendar.weeks | .[].contributionDays |.[] | {date: (.date), num:(.contributionCount)}]' > out.json

Then you can generate the calendar with

go run github.com/Its-Just-Nans/go-calendar -k date -c num -i out.json -o contributions.svg

License

License MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL