Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mor1/ocal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.2.1
Choose a base ref
...
head repository: mor1/ocal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 11 commits
  • 24 files changed
  • 1 contributor

Commits on Nov 10, 2018

  1. dunification: rename jbuild

    Signed-off-by: Richard Mortier <[email protected]>
    mor1 committed Nov 10, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    bb0112c View commit details
  2. dunification: builds, installs ok

    Signed-off-by: Richard Mortier <[email protected]>
    mor1 committed Nov 10, 2018
    Copy the full SHA
    2e12e95 View commit details
  3. opam: update to opam.2.0

    Signed-off-by: Richard Mortier <[email protected]>
    mor1 committed Nov 10, 2018
    Copy the full SHA
    1cefe01 View commit details
  4. opam: using https causes lint to whine; using git fails

    Signed-off-by: Richard Mortier <[email protected]>
    mor1 committed Nov 10, 2018
    Copy the full SHA
    752eb50 View commit details
  5. opam: remove em-dash causing problems; tweak Makefile

    Signed-off-by: Richard Mortier <[email protected]>
    mor1 committed Nov 10, 2018
    Copy the full SHA
    7063f4e View commit details

Commits on Nov 12, 2018

  1. opam: fix run-test/build ... {with-test} confusion

    Signed-off-by: Richard Mortier <[email protected]>
    mor1 committed Nov 12, 2018
    Copy the full SHA
    5bcb1e9 View commit details

Commits on Nov 13, 2018

  1. opam: remove ocamlfind dep; dune: new @all target

    Signed-off-by: Richard Mortier <[email protected]>
    mor1 committed Nov 13, 2018
    Copy the full SHA
    dd06c03 View commit details

Commits on Aug 21, 2023

  1. ocal: bump dependency versions

    mor1 committed Aug 21, 2023
    Copy the full SHA
    2f311d8 View commit details

Commits on Aug 29, 2023

  1. Copy the full SHA
    13971e7 View commit details

Commits on May 31, 2024

  1. reuse: add licensing info per reuse

    ```bash
    reuse annotate --copyright="Richard Mortier <[email protected]>" --license=ISC --year 2024 --merge-copyrights --recursive --skip-unrecognised .
    ```
    mor1 committed May 31, 2024
    Copy the full SHA
    6bb1296 View commit details

Commits on Jan 16, 2025

  1. Copy the full SHA
    8ef8631 View commit details
Showing with 363 additions and 273 deletions.
  1. +5 −0 .gitignore
  2. 0 .ocamlformat
  3. +10 −0 .reuse/dep5
  4. +6 −0 .vscode/settings.json
  5. +3 −0 .vscode/settings.json.license
  6. +12 −3 CHANGES.md
  7. +60 −0 Justfile
  8. +8 −0 LICENSE
  9. +0 −13 LICENSE.md
  10. +40 −20 Makefile
  11. +6 −0 README.md
  12. +3 −0 doc/api.odocl.license
  13. +21 −0 dune-project
  14. +25 −21 ocal.opam
  15. +3 −0 ocal.opam.license
  16. +9 −5 pkg/pkg.ml
  17. +6 −0 src/config.ml
  18. +2 −4 src/day.ml
  19. +8 −13 src/days.ml
  20. +11 −0 src/dune
  21. +0 −17 src/jbuild
  22. +46 −55 src/main.ml
  23. 0 src/main.mli
  24. +79 −122 src/ocal.ml
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>
#
# SPDX-License-Identifier: ISC

_build
*.merlin
*.install
_opam
Empty file added .ocamlformat
Empty file.
10 changes: 10 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ocal
Upstream-Contact: Richard Mortier <mort@cantab.net>
Source: https://github.com/mor1/ocal

# Sample paragraph, commented out:
#
# Files: src/*
# Copyright: $YEAR $NAME <$CONTACT>
# License: ...
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ocaml.sandbox": {
"kind": "opam",
"switch": "${workspaceFolder:ocal}"
}
}
3 changes: 3 additions & 0 deletions .vscode/settings.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>

SPDX-License-Identifier: ISC
15 changes: 12 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
### 0.2.2 (2018-11-10)

* Dunification

### 0.2.1 (2017-11-30)

* Update to use [notty][] 0.2.0 after breaking API change
* Update to use [notty](https://pqwy.github.io/notty) 0.2.0 after breaking API
change
* Change default to display week-of-year; `-w` now stops display
* Fix compiler and library constraints
* Fix display of current month by default

### 0.2.0 (2017-08-28)

* Update `pkg/pkg.ml` to *not* build docs during `topkg publish`
* Use [notty][] for layout
* Use [notty](https://pqwy.github.io/notty) for layout
* Add option to display week-of-year
* Set timezone to be Local rather than UTC

@@ -26,4 +31,8 @@

* Initial release

[notty]: https://pqwy.github.io/notty
<!--
SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>
SPDX-License-Identifier: ISC
-->
60 changes: 60 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>
#
# SPDX-License-Identifier: ISC

_default:
@just --list

PWD := env("PWD")
DOCDIR := "_build/default/_doc/_html"
BUILDDIR := "_build/install/default/bin"
TARGET := "ocal"

# build targets
build:
dune build @all

# cleanup
clean:
dune clean

# install targets
install: build
dune build @install
ln -sf {{PWD}}/{{BUILDDIR}}/{{TARGET}} ~/.local/bin/

# uninstall targets
uninstall:
dune uninstall

# run any tests
test:
dune runtest

# format sources
format:
dune fmt

# lint everything
lint:
dune build @lint
dune-release lint

# build docs
doc:
dune build @doc
dune build @doc-private

# open the docs for reading
read: doc
handlr open {{DOCDIR}}/index.html || open {{DOCDIR}}

# tag and create a release
release:
dune-release tag
dune-release -vv

# install dependencies
depends:
opam install --yes dune-release odoc
opam install --yes . --deps-only
8 changes: 8 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ISC License:

Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
Copyright (c) 1995-2003 by Internet Software Consortium

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
13 changes: 0 additions & 13 deletions LICENSE.md

This file was deleted.

60 changes: 40 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
.PHONY: build clean test install uninstall distrib publish release
# SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>
#
# SPDX-License-Identifier: ISC

DOCDIR = _build/default/_doc/_html/

.default: build

.PHONY: build
build:
jbuilder build @install --dev
dune build @all

.PHONY: clean
clean:
jbuilder clean

test:
jbuilder runtest --dev
dune clean

.PHONY: install
install:
jbuilder install
dune build @install
ln -sf ~/u/src/ocal/_build/install/default/bin/ocal ~/.local/bin/

.PHONY: uninstall
uninstall:
jbuilder uninstall
dune uninstall

distrib:
[ -x $$(opam config var root)/plugins/opam-publish/repos/ocal ] || \
opam-publish repo add ocal mor1/ocal
topkg tag
topkg distrib

publish:
topkg publish
topkg opam pkg
topkg opam submit

release: distrib publish
.PHONY: test
test:
dune runtest

.PHONY: lint
lint:
dune build @lint
dune-release lint

.PHONY: doc
doc:
opam list -i --silent odoc || opam install -y odoc
dune build @doc
dune build @doc-private

.PHONY: read
read: doc
open $(DOCDIR)/index.html || open $(DOCDIR)

.PHONY: release
release:
opam list -i --silent dune-release || opam install -y dune-release
dune-release tag
dune-release -vv
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,3 +4,9 @@

A replacement for the standard Unix `cal` utility. Partly because I could,
partly because I'd become too irritated with its command line interface.

<!--
SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>
SPDX-License-Identifier: ISC
-->
3 changes: 3 additions & 0 deletions doc/api.odocl.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>

SPDX-License-Identifier: ISC
21 changes: 21 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(lang dune 3.17)

(name ocal)

(generate_opam_files true)

(source
(github mor1/ocal))

(authors "Richard Mortier <mort@cantab.net>")

(maintainers "Richard Mortier <mort@cantab.net>")

(license MIT)

(package
(name ocal)
(synopsis "An improved UNIX `cal` utility")
(description "Replace `cal` because I could and because I find the CLI irritating")
(tags
()))
46 changes: 25 additions & 21 deletions ocal.opam
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
opam-version: "1.2"
maintainer: "Richard Mortier <mort@cantab.net>"
authors: [ "Richard Mortier" ]
license: "ISC"

# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "An improved UNIX `cal` utility"
description:
"Replace `cal` because I could and because I find the CLI irritating"
maintainer: ["Richard Mortier <mort@cantab.net>"]
authors: ["Richard Mortier <mort@cantab.net>"]
license: "MIT"
homepage: "https://github.com/mor1/ocal"
dev-repo: "https://github.com/mor1/ocal.git"
bug-reports: "https://github.com/mor1/ocal/issues"
doc: "https://mor1.github.io/ocal/"

available: [ ocaml-version >= "4.02.3" ]

build: [
[ "jbuilder" "subst" ] {pinned}
[ "jbuilder" "build" "-p" name "-j" jobs ]
]

depends: [
"ocamlfind" {build}
"jbuilder" {build & >="1.0+beta11"}
"astring" {build}
"calendar" {build}
"cmdliner" {build}
"notty" {build & >="0.2.0"}
"dune" {>= "3.17"}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mor1/ocal.git"
3 changes: 3 additions & 0 deletions ocal.opam.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>

SPDX-License-Identifier: ISC
14 changes: 9 additions & 5 deletions pkg/pkg.ml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/usr/bin/env ocaml

(*
* SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>
*
* SPDX-License-Identifier: ISC
*)
#use "topfind"

#require "topkg-jbuilder"

open Topkg

let publish =
Pkg.publish ~artefacts:[`Distrib] ()

let () =
Topkg_jbuilder.describe ~publish ()
let publish = Pkg.publish ~artefacts:[ `Distrib ] ()
let () = Topkg_jbuilder.describe ~publish ()
6 changes: 6 additions & 0 deletions src/config.ml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
(*
* SPDX-FileCopyrightText: 2024 Richard Mortier <mort@cantab.net>
*
* SPDX-License-Identifier: ISC
*)

let version = "%%VERSION%%"
let command = "%%NAME%%"
6 changes: 2 additions & 4 deletions src/day.ml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
(*
* Copyright (c) 2016-2017 Richard Mortier <mort@cantab.net>
*
* Licensed under the ISC Licence; see LICENSE.md in the root of this
* distribution or the full text at https://opensource.org/licenses/isc-license
* SPDX-FileCopyrightText: 2016 - 2024 Richard Mortier <mort@cantab.net>
*
* SPDX-License-Identifier: ISC
*)

open CalendarLib
21 changes: 8 additions & 13 deletions src/days.ml
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
(*
* Copyright (c) 2016-2017 Richard Mortier <mort@cantab.net>
*
* Licensed under the ISC Licence; see LICENSE.md in the root of this
* distribution or the full text at https://opensource.org/licenses/isc-license
* SPDX-FileCopyrightText: 2016 - 2024 Richard Mortier <mort@cantab.net>
*
* SPDX-License-Identifier: ISC
*)

open CalendarLib

let of_week firstday =
let days = Date.([| Mon; Tue; Wed; Thu; Fri; Sat; Sun;
Mon; Tue; Wed; Thu; Fri; Sat; Sun
|])
let days =
Date.
[| Mon; Tue; Wed; Thu; Fri; Sat; Sun; Mon; Tue; Wed; Thu; Fri; Sat; Sun |]
in
let find x =
let rec aux a x n = if a.(n) = x then n else aux a x (n+1) in
let rec aux a x n = if a.(n) = x then n else aux a x (n + 1) in
aux days x 0
in

Array.sub days (find firstday) 7
|> Array.to_list
Array.sub days (find firstday) 7 |> Array.to_list

let of_month monthyear =
let length = Date.days_in_month monthyear in
let rec aux a b =
if a > b then [] else a :: aux (a+1) b
in
let rec aux a b = if a > b then [] else a :: aux (a + 1) b in
aux 1 length
Loading