Skip to content

Its-Just-Nans/go-calendar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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