Skip to content

Commit

Permalink
Merge pull request #1 from budlabs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
budRich committed Feb 2, 2019
2 parents 6bb5e60 + 356e785 commit c4f8191
Show file tree
Hide file tree
Showing 15 changed files with 245 additions and 68 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,32 @@ See the [bashbud wiki] or the manpage `bashbud(1)` for a
detailed description on how **bashbud** works and what it
can do.

[bashbud wiki]: https://github.com/budRich/bashbud/wiki %%%WRAPTHIS%%%[AUR]: https://aur.archlinux.org/packages/bashbud
[bashbud wiki]: https://github.com/budRich/bashbud/wiki
[AUR]: https://aur.archlinux.org/packages/bashbud


## updates

**2019-02-02**
New feature, bump script directories, read more in the
wiki:
https://github.com/budlabs/bashbud/wiki/05CA_bump_scripts


Fixed an issue where link definitions in markdown got
interpreted as paragraphs resulting in an embarrassing
parsing error in the main readme of this repo.


**2019-01-01**
Lots of improvements bug fixes. Two new command line
options (`--get` and `--set`) to get/set values from the
YAML of a projects **manifest.md**.


## BUD IS BACK


**2019-01-01**
First public release, read the wiki, report the issues,
stay calm and keep kyle.
Expand Down
22 changes: 16 additions & 6 deletions awklib/mdcat.awk
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ function mdcat(e,k,r,incode,mdbody,mdline,thisline,lastline) {
thisline="table"
}

# line ending with doublespace
else if (mdline ~ /.*[ ]{2,}$/) {
thisline="dspace"
}

# link definition [link]: url
else if (mdline ~ /^[[].+[]]:.*/) {
thisline="linkdef"
}

# line ending with doublespace
else if (mdline ~ /.*[ ]{2,}$/) {
thisline="dspace"
}

# HR
else if (mdline ~ /^[-].*/) {
thisline="hr"
Expand Down Expand Up @@ -72,19 +72,29 @@ function mdcat(e,k,r,incode,mdbody,mdline,thisline,lastline) {
}
else {

if (lastline == "linkdef" && thisline != "linkdef") {
r = r "\n"
}

if (thisline == "table") {
if (lastline != "table")
r = r "\n"
r = r mdline "\n"
}

if (thisline == "linkdef") {
if (lastline != "linkdef")
r = r "\n"
r = r mdline "\n"
}

if (lastline ~ /normal|dspace/) {
if (!(thisline ~ /normal|dspace/ && lastline=="normal")) {
r=r "%%%WRAPTHIS%%%"
}
}

if (thisline ~ /code|linkdef/) {
if (thisline ~ /code/) {
r=r mdline "\n"
}

Expand Down
60 changes: 59 additions & 1 deletion bashbud.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH BASHBUD 1 2019\-01\-08 Linx "User Manuals"
.TH BASHBUD 1 2019\-02\-02 Linx "User Manuals"
.SH NAME
.PP
\fB\fCbashbud\fR \- Generate documents and manage
Expand Down Expand Up @@ -1943,6 +1943,64 @@ This will increment the version number in the
manifest front matter +0.001 and update the
updated date, before any templates are processed.

.PP
It is also possible to execute more scripts by
adding them to directories named: \fB\fC\_\_pre\-apply.d\fR
and/or \fB\fC\_\_post\-apply.d\fR , an optional \fB\fC\_\_order\fR
file can also be created in these directories to
specify a desired execution order.

.SH EXAMPLE
.PP
.RS

.nf
PROJECT\_DIR/bashbud
...
\_\_pre\-apply.d
notify
\_\_order
\_\_pre\-apply
...

.fi
.RE

.PP
\fBPROJECT\_DIR/bashbud/\_\_pre\-apply.d/notify\fP

.PP
.RS

.nf
#!/usr/bin/env bash
notify\-send "Let's generate!"

.fi
.RE

.PP
\fBPROJECT\_DIR/bashbud/\fBpre\-apply.d/\fPorder\fP

.PP
.RS

.nf
# order to execute pre\-apply scripts
notify
banana

.fi
.RE

.PP
With this setup, the \fB\fC\_\_pre\-apply\fR script will
first get executed. The the order will get
determined. In the example \fB\fC\_\_order\fR file above to
files are listed \fBnotify\fP and \fBbanana\fP, since
\fBbanana\fP doesn't exist, only \fBnotify\fP will get
executed.

.SH generator scripts
.PP
Whenever a project is created with the \fB\fC\-\-new\fR
Expand Down
28 changes: 13 additions & 15 deletions bashbud/__pre-apply
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/usr/bin/env bash

# increment version number
# i3ass specific __pre-apply

# increment version numbers
# set updated to today in manifest.md

today="$(date +%Y-%m-%d)"
projectdir=$1
manifest="$projectdir/manifest.md"
projectdir="$1"
newver="$(date +%Y.%m.%d).0"
curver="$(bashbud --get version)"

[[ ${newver%.*} = "${curver%.*}" ]] && {
controldigit="${curver##*.}"
newver="${newver%.*}.$((controldigit+1))"
}

awk -i inplace -v today="$today" '
$1 == "version:" {
newver=$2 + 0.001
sub($2,newver,$0)
bump=0
}
$1 == "updated:" {
sub($2,today,$0)
}
{print}
' "$manifest"
bashbud --set version "$newver" "$projectdir"
bashbud --set updated "$(date +%Y-%m-%d)" "$projectdir"
4 changes: 2 additions & 2 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
___printversion(){

cat << 'EOB' >&2
bashbud - version: 1.298
updated: 2019-01-08 by budRich
bashbud - version: 2019.02.02.18
updated: 2019-02-02 by budRich
EOB
}

Expand Down
17 changes: 17 additions & 0 deletions lib/bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,32 @@ bumpproject(){
fi
fi


# execute any pre-apply script
[[ -x "$templatedir/__pre-apply" ]] \
&& "$templatedir/__pre-apply" "$projectdir"

# if __pre-apply.d dir exist, execute scripts
if [[ -d "$templatedir/__pre-apply.d" ]]; then
for f in $(getorder "$templatedir/__pre-apply.d"); do
[[ -x "$f" ]] || continue
"$f" "$projectdir"
done
fi

# process manifest and templates
setstream "$projectdir" "$templatedir" "${licensetemplate:-}" \
| generate "$projectdir"

# execute any post-apply script
[[ -x "$templatedir/__post-apply" ]] \
&& "$templatedir/__post-apply" "$projectdir"

# if __post-apply.d dir exist, execute scripts
if [[ -d "$templatedir/__post-apply.d" ]]; then
for f in $(getorder "$templatedir/__pre-apply.d"); do
[[ -x "$f" ]] || continue
"$f" "$projectdir"
done
fi
}
18 changes: 18 additions & 0 deletions lib/getorder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

getorder() {
local trgdir="$1"

[[ -d $trgdir ]] || return 1

if [[ -f "$trgdir/__order" ]]; then
awk '
/^[^#]/ && $0 !~ /^\s*$/ {print}
' "$trgdir/__order"
ls "$trgdir" | grep -v '^__'
else
ls "$trgdir" | grep -v '^__'
fi | awk -v d="$trgdir" '
!a[$0]++ {print d "/" $0}
'
}
18 changes: 1 addition & 17 deletions lib/setstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ setstream() {
local templatedir="$2"
local licensetemplate="${3:-}"

local templatelist

cat "$projectdir/manifest.md"
[[ -d $projectdir/manifest.d ]] && {
for f in "$projectdir/manifest.d/"*; do
Expand All @@ -15,21 +13,7 @@ setstream() {
}
echo "___START___"

# make a list of all templates,
# with __order in mind.
templatelist="$(
if [[ -f "$templatedir/__order" ]]; then
awk '
/^[^#]/ && $0 !~ /^\s*$/ {print}
' "$templatedir/__order"
ls "$templatedir" | grep -v '^__'
else
ls "$templatedir" | grep -v '^__'
fi | awk -v d="$templatedir" '
!a[$0]++ {print d "/" $0}
')"

for d in ${templatelist}; do
for d in $(getorder "$templatedir"); do
[[ -d $d ]] || continue

[[ -f $d/__template ]] && {
Expand Down
1 change: 1 addition & 0 deletions manifest.d/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ See the [bashbud wiki] or the manpage `bashbud(1)` for a detailed description on

[bashbud wiki]: https://github.com/budRich/bashbud/wiki
[AUR]: https://aur.archlinux.org/packages/bashbud

4 changes: 2 additions & 2 deletions manifest.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
description: >
Generate documents and manage projects
updated: 2019-01-08
version: 1.298
updated: 2019-02-02
version: 2019.02.02.7
author: budRich
repo: https://github.com/budlabs
created: 2018-09-20
Expand Down
48 changes: 44 additions & 4 deletions manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1428,10 +1428,6 @@ performed **bashbud** looks for files named and
located in certain places, if these files exist
and is executable, they will be executed.





## template scripts


Expand Down Expand Up @@ -1543,6 +1539,50 @@ This will increment the version number in the
manifest front matter +0.001 and update the
updated date, before any templates are processed.

It is also possible to execute more scripts by
adding them to directories named: `__pre-apply.d`
and/or `__post-apply.d` , an optional `__order`
file can also be created in these directories to
specify a desired execution order.

EXAMPLE
-------


```text
PROJECT_DIR/bashbud
...
__pre-apply.d
notify
__order
__pre-apply
...
```


**PROJECT_DIR/bashbud/__pre-apply.d/notify**
```
#!/usr/bin/env bash
notify-send "Let's generate!"
```



**PROJECT_DIR/bashbud/__pre-apply.d/__order**
```
# order to execute pre-apply scripts
notify
banana
```


With this setup, the `__pre-apply` script will
first get executed. The the order will get
determined. In the example `__order` file above to
files are listed **notify** and **banana**, since
**banana** doesn't exist, only **notify** will get
executed.

## generator scripts


Expand Down
Loading

0 comments on commit c4f8191

Please sign in to comment.