Initial commit

This commit is contained in:
Kaustubh Maske Patil 2024-07-20 03:37:17 +05:30
commit 0c6fd957dd
10 changed files with 141 additions and 0 deletions

31
.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
*.annot
*.cmo
*.cma
*.cmi
*.a
*.o
*.cmx
*.cmxs
*.cmxa
# ocamlbuild working directory
_build/
# ocamlbuild targets
*.byte
*.native
# oasis generated files
setup.data
setup.log
# Merlin configuring file for Vim and Emacs
.merlin
# Dune generated files
*.install
# Local OPAM switch
_opam/
.DS_Store

4
bin/dune Normal file
View File

@ -0,0 +1,4 @@
(executable
(public_name boks)
(name main)
(libraries boks))

21
bin/main.ml Normal file
View File

@ -0,0 +1,21 @@
open Boks
let usage_msg = "boks -p <padding size> -a <arrow size> <text1> [<text2>] ..."
let padlen = ref 3
let arrowlen = ref 3
let texts = ref []
let accept_text t =
texts := !texts @ [t]
let speclist = [
("-p", Arg.Set_int padlen, "Padding size");
("-a", Arg.Set_int arrowlen, "Arrow size");
]
let () =
Arg.parse speclist accept_text usage_msg;
let padlen = !padlen in
let arrowlen = !arrowlen in
let texts = !texts in
boks ~padlen ~arrowlen texts

31
boks.opam Normal file
View File

@ -0,0 +1,31 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "A short synopsis"
description: "A longer description"
maintainer: ["Maintainer Name"]
authors: ["Author Name"]
license: "LICENSE"
tags: ["topics" "to describe" "your" "project"]
homepage: "https://github.com/username/reponame"
doc: "https://url/to/documentation"
bug-reports: "https://github.com/username/reponame/issues"
depends: [
"ocaml"
"dune" {>= "3.13"}
"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/username/reponame.git"

26
dune-project Normal file
View File

@ -0,0 +1,26 @@
(lang dune 3.13)
(name boks)
(generate_opam_files true)
(source
(github username/reponame))
(authors "Author Name")
(maintainers "Maintainer Name")
(license LICENSE)
(documentation https://url/to/documentation)
(package
(name boks)
(synopsis "A short synopsis")
(description "A longer description")
(depends ocaml dune)
(tags
(topics "to describe" your project)))
; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project

22
lib/boks.ml Normal file
View File

@ -0,0 +1,22 @@
let bok_edge padlen text =
Printf.sprintf "+%s+" (String.make (String.length text + 2 * padlen) '-')
let bok_core padlen text =
let padding = String.make padlen ' ' in
Printf.sprintf "|%s%s%s|" padding text padding
let arrow len =
Printf.sprintf "<%s>" (String.make len '-')
let boks ?(padlen=3) ?(arrowlen=3) texts =
let conn = arrow arrowlen in
let conn_space = String.make (String.length conn) ' ' in
let boks_edge = String.concat
conn_space
(List.map (bok_edge padlen) texts)
in
let boks_core = String.concat
conn
(List.map (bok_core padlen) texts)
in
Printf.printf "%s\n%s\n%s\n" boks_edge boks_core boks_edge

1
lib/boks.mli Normal file
View File

@ -0,0 +1 @@
val boks : ?padlen:int -> ?arrowlen:int -> string list -> unit

3
lib/dune Normal file
View File

@ -0,0 +1,3 @@
(library
(name boks)
(modules boks))

2
test/dune Normal file
View File

@ -0,0 +1,2 @@
(test
(name test_boks))

0
test/test_boks.ml Normal file
View File