make: create a new file
- Creates a templates and a notes directory. - Creates a default template used to create new files. It contains a minimal frontmatter with the creation date and an ID. - Adds the *new* recipe which creates a new file in the notes directory, based on the default template, replacing the creation date and ID variables with according values. - Updates the README file with the new recipe. - Improves the documentation of the code with comments. - Fixes #9. Co-Authored-by: iGor milhit <igor@milhit.ch>new-file
parent
a388b69b41
commit
803ad9ce15
26
Makefile
26
Makefile
|
@ -6,10 +6,27 @@
|
|||
.DEFAULT_GOAL:=help
|
||||
SHELL:=/bin/bash
|
||||
|
||||
# Get the output of the pandoc command
|
||||
pandoc=$(shell command -v pandoc)
|
||||
# Get the version of pandoc
|
||||
pandoc_version=$(shell pandoc --version | sed -e 's/.* // ; 1q')
|
||||
# Get the output of the awk command
|
||||
awk=$(shell command -v awk)
|
||||
|
||||
# Get the datetime
|
||||
now=$(shell date +%Y%m%d%H%M%S)
|
||||
# Build the filename
|
||||
filename=$(now).md
|
||||
|
||||
# Export date and id as environment variable to replace the variables in the
|
||||
# template file
|
||||
export date:=$(shell date +%Y-%m-%dT%H:%M:%S%:z)
|
||||
export id:=$(now)
|
||||
|
||||
# Set the templates and notes directories
|
||||
templates_directory=templates
|
||||
notes_directory=notes
|
||||
|
||||
.PHONY: help deps
|
||||
|
||||
help: ## Display this help
|
||||
|
@ -18,12 +35,17 @@ help: ## Display this help
|
|||
deps: ## Check dependencies
|
||||
$(info Checking and getting dependencies)
|
||||
ifeq ($(strip ($pandoc)),)
|
||||
@echo "pandoc is required"
|
||||
@echo "pandoc is required and not installed"
|
||||
else
|
||||
@echo "pandoc" $(pandoc_version) "is installed"
|
||||
endif
|
||||
ifeq ($(strip ($awk)),)
|
||||
@echo "awk is required"
|
||||
@echo "awk is required and not installed"
|
||||
else
|
||||
@echo "awk is installed"
|
||||
endif
|
||||
|
||||
new: ## Create a new file
|
||||
$(info Creating a new file)
|
||||
@ envsubst <$(templates_directory)/default.md >$(notes_directory)/$(filename)
|
||||
$(info Your new file is $(notes_directory)/$(filename))
|
||||
|
|
15
README.md
15
README.md
|
@ -29,10 +29,16 @@ notamment pour pouvoir gérer les citations et les références avec
|
|||
|
||||
## Fonctionnalités
|
||||
|
||||
Pour l'instant [`make-pandoc`][mp] ne fait strictement rien. Mais dans un
|
||||
avenir incertain il devrait être en mesure de générer une version `HTML` d'une
|
||||
arborescence de fichiers Markdown, en offrant une navigation, la mise en forme
|
||||
des citations et des références, des notes.
|
||||
`make-pandoc` est en mesure :
|
||||
|
||||
- D'afficher une aide (`make` ou `make help`).
|
||||
- De vérifier si les dépendances sont bien installées (`make deps`).
|
||||
- De créer un nouveau fichier dans le répertoire de notes (`make new`).
|
||||
|
||||
Pour l'instant [`make-pandoc`][mp] ne fait pas grand chose de plus. Mais dans
|
||||
un avenir incertain il devrait être en mesure de générer une version `HTML`
|
||||
d'une arborescence de fichiers Markdown, en offrant une navigation, la mise en
|
||||
forme des citations et des références, des notes.
|
||||
|
||||
## Requis
|
||||
|
||||
|
@ -68,6 +74,7 @@ Usage:
|
|||
Targets:
|
||||
help Display this help
|
||||
deps Check dependencies
|
||||
new Create a new file
|
||||
```
|
||||
|
||||
## Feuille de route
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
date: $date
|
||||
id: $id
|
||||
---
|
||||
|
||||
|
Loading…
Reference in New Issue