8000 GitHub - d6o/opcal: A Go library and CLI tool for generating customizable, localized One Page Calendars in multiple formats
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ opcal Public

A Go library and CLI tool for generating customizable, localized One Page Calendars in multiple formats

License

Notifications You must be signed in to change notification settings

d6o/opcal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opcal: OnePageCalendar Language Badge Go Report License Badge Status Badge GoDoc

opcal is a Go library and CLI tool designed to generate a One Page Calendar—a compact, easy-to-read calendar format that displays an entire year at a glance. This single-page layout makes it ideal for quickly referencing dates, planning events, or embedding a calendar into reports or applications. OpCal supports extensive customization options for colors, styles, and output formats, as well as localization, allowing you to tailor month and weekday names for different languages and regions.

opcal


Features

  • CLI Tool: Quickly generate a styled calendar for any year from the command line.
  • Library Usage: Integrate OpCal into your Go projects as a library.
  • Custom Styling: Customize colors, layout, and text labels.
  • Multiple Formats: Output calendars as text, CSV, HTML, Markdown, or TSV.
  • Highlight Current Year and Date: Automatically highlights the current month and date if applicable.
  • Localization Support: Change month and weekday names for internationalization.

Installation

Using Go Install

You can install the opcal CLI tool directly using go install:

  1. Install the package:

    go install github.com/d6o/opcal/cmd/opcal@latest
  2. Make sure that GOPATH is in your PATH:

    export PATH=$PATH:$(go env GOPATH)/bin
  3. Execute opcal

    opcal 1992

Using CLI Tool

  1. Clone the repository:

    git clone https://github.com/d6o/opcal.git
  2. Build the CLI tool:

    cd opcal/cmd/opcal
    go build -o opcal
  3. Call opcal

     ./opcal 2024

As a Library

Add OpCal as a dependency in your project:

go get github.com/d6o/opcal

CLI Usage

Run the tool from the command line:

./opcal [year]
  • If no year is specified, the current year will be used.

opcal


Library Usage

Here is an example of using OpCal as a library in your Go project:

Add OpCal as a dependency in your project:

go get github.com/d6o/opcal

Example:

package main

import (
	"fmt"
	"github.com/d6o/opcal"
)

func main() {
	year := 2025
	calendar := opcal.New()
	fmt.Println(calendar.String(year))
}

Customization Example

OpCal provides options for deep customization.

Styling Options

You can customize the colors and styles using the following methods:

  • SetColorMonthDefault(colors text.Colors)
  • SetColorMonthHighlight(colors text.Colors)
  • SetColorDayDefault(colors text.Colors)
  • SetColorDayHighlight(colors text.Colors)
  • SetColorWeekdayDefault(colors text.Colors)
  • SetColorWeekdayHighlight(colors text.Colors)
  • SetStyle(s table.Style)

Localization Options

You can localize the strings using the following methods:

  • SetShortMonths(months []string) error
  • SetShortWeekdays(weekdays []string) error
  • SetDateHeader(header string)

Example

Here is an example of changing styles and text:

package main

import (
	"fmt"
	"github.com/d6o/opcal"
	"github.com/jedib0t/go-pretty/v6/table"
	"github.com/jedib0t/go-pretty/v6/text"
)

func main() {
	calendar := opcal.New()
	calendar.SetShortMonths([]string{"Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dec"})
	calendar.SetShortWeekdays([]string{"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"})
	calendar.SetColorDayDefault(text.Colors{text.FgBlue})
	calendar.SetStyle(table.StyleColoredDark)

	fmt.Println(calendar.String(2025))
}

Output Formats

OpCal supports the string, CSV, HTML, Markdown and TSV output formats.

Text

calendar.String(2025)

CSV

calendar.CSV(2025)

HTML

calendar.HTML(2025)

Markdown

calendar.Markdown(2025)

TSV

calendar.TSV(2025)

Error Handling

Library Errors

  • ErrInvalidShortMonths: Returned when setting invalid month names.
  • ErrInvalidShortWeekdays: Returned when setting invalid weekday names.

CLI Tool Errors

If an invalid year is provided as a command-line argument, the tool defaults to the current year.


Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve OpCal.

  1. Create an issue to discuss about your idea
  2. [Fork it] (https://github.com/d6o/opcal/fork)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request
  7. Profit! ✅

Author

OpCal is developed by d6o.


License

The MIT License (MIT)

Copyright (c) 2013-2018 Diego Siqueira

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A Go library and CLI tool for generating customizable, localized One Page Calendars in multiple formats

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0