From 09185557a67a1216b9c61d7a7055f347632df07d Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sun, 24 Jan 2021 22:24:22 -0500 Subject: [PATCH] First commit Create shell for program --- LICENSE | 21 +++++++++++++++++++++ Makefile | 19 +++++++++++++++++++ README.md | 5 +++++ contrib/example.md | 6 ++++++ contrib/manconvert | 2 ++ lightcards.py | 23 +++++++++++++++++++++++ man/lightcards.1.md | 35 +++++++++++++++++++++++++++++++++++ requirements.txt | 3 +++ 8 files changed, 114 insertions(+) create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 contrib/example.md create mode 100755 contrib/manconvert create mode 100755 lightcards.py create mode 100644 man/lightcards.1.md create mode 100644 requirements.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e1300da --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +Lightcards - Simple flashcards in the terminal +Copyright © 2021 Armaan Bhojwani + +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. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b6b6727 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +.DEFAULT_GOAL := install + +prep: + mkdir -p /usr/local/bin + mkdir -p /usr/local/man/man1 + +install: + make prep + mkdir -p /usr/local/share/lightcards/ + cp lightcards.py /usr/local/bin/lightcards + cp man/lightcards.1 /usr/local/man/man1/ + +uninstall: + rm /usr/local/bin/lightcards + rm /usr/local/man/man1/lightcards.1 + +reinstall: + make uninstall + make install diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a1b5dc --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# lightcards +Lightcards is a simple terminal program for creating flashcards from a markdown table + +## License +Copyright Armaan Bhojwani 2021, MIT license diff --git a/contrib/example.md b/contrib/example.md new file mode 100644 index 0000000..a6213bd --- /dev/null +++ b/contrib/example.md @@ -0,0 +1,6 @@ +| Side 1 | Side 2 | +|-------------------------|-----------------------| +| This is a front side | This is a back side | +| Card 2 | Card 2b | +| Random data random data | Answer to random data | +| 42 | no! | diff --git a/contrib/manconvert b/contrib/manconvert new file mode 100755 index 0000000..4fad1cb --- /dev/null +++ b/contrib/manconvert @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +pandoc $1 -s -t man -o $(echo $1 | cut -d '.' -f -2) diff --git a/lightcards.py b/lightcards.py new file mode 100755 index 0000000..191afcd --- /dev/null +++ b/lightcards.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# Simple markdown flashcards utility +# Armaan Bhojwani 2021 + +import argparse +import sys +from bs4 import BeautifulSoup +from blessings import Terminal +import markdown + + +def parse_args(): + parser = argparse.ArgumentParser(description="Simple terminal flashcards") + parser.add_argument("inp", metavar="inp", type=str, nargs=1) + return parser.parse_args() + +def main(): + pass + +if __name__ == "__main__": + args = parse_args() + t = Terminal() + main() diff --git a/man/lightcards.1.md b/man/lightcards.1.md new file mode 100644 index 0000000..42259ec --- /dev/null +++ b/man/lightcards.1.md @@ -0,0 +1,35 @@ +% lightcards(1) 0.0.0 +% Armaan Bhojwani +% January 2021 + +# NAME +Lightcards - simple terminal flashcards. + +# SYNOPSIS +lightcards [[options]] [[input file]] + +# DESCRIPTION +**lightcards** is a Python script that reads data from a markdown table, and creates flashcards from them. + +# OPTIONS +**-h**, **--help** +: Show a help message and exit + +**-v**, **--version** +: Print version + +# EXIT VALUES +**0** +: Success + +**1** +: Cannot find input file + +**2** +: Invalid option + +# BUGS, PATCHES +https://lists.sr.ht/~armaan/public-inbox + +# COPYRIGHT +Copyright 2021 Armaan Bhojwani . MIT License diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..aaa9d9d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +beautifulsoup4==4.9.3 +blessings==1.7 +markdown==3.3.3 -- 2.39.2