Use a pre-build script to generate usage.h from the README.md

Use a generated header from README.md
Finalise git ignore file
This commit is contained in:
mdiluzio 2014-12-20 15:35:16 +00:00
parent a7bc45497a
commit 71d0084908
5 changed files with 35 additions and 66 deletions

11
.gitignore vendored
View file

@ -1,5 +1,12 @@
build/ # Build directory
maps/ /build/
# Built binary and maps
/maps/
/ttrts
# user files
*.user *.user
*.sublime* *.sublime*
*.idea *.idea

9
source/scripts/gen_usage.sh Executable file
View file

@ -0,0 +1,9 @@
#! /bin/bash
# Used to generate usage text from markdown
cat README.md \
| sed 's/^#* //g' \
| sed 's/\t/\\t/g' \
| sed ':a;N;$!ba;s/\n/\\n\n/g' \
| sed 's/^/\"/' \
| sed 's/$/\"/' \
> $1

View file

@ -3,6 +3,7 @@
project( ttrts ) project( ttrts )
include_directories( include_directories(
${CMAKE_CURRENT_BINARY_DIR}
../maths ../maths
../game ../game
) )
@ -13,6 +14,16 @@ set( SOURCES
) )
# Add the executable # Add the executable
add_executable( ttrts ${SOURCES} ) add_executable( ${PROJECT_NAME} ${SOURCES} )
target_link_libraries( ttrts game ) target_link_libraries( ${PROJECT_NAME} game )
# Installation target
install( TARGETS ${PROJECT_NAME} DESTINATION bin )
# Run the gen_usage script to generate our usage header
add_custom_target(
gen_ttrts_usage
cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_SOURCE_DIR}/scripts/gen_usage.sh "${CMAKE_CURRENT_BINARY_DIR}/usage.h"
)
add_dependencies(${PROJECT_NAME} gen_ttrts_usage)

View file

@ -2,7 +2,7 @@
ttrts - Tiny Terminal RTS ttrts - Tiny Terminal RTS
## SYNOPSYS ## SYNOPSYS
ttrts [OPTIONS...] MAPFILE ttrts MAPFILE
## DESCRIPTION ## DESCRIPTION
ttrts is a tiny terminal based RTS where that uses text ttrts is a tiny terminal based RTS where that uses text
@ -50,8 +50,6 @@
... ...
### Orders ### Orders
F - Move unit forward one space F - move unit [F]orward one space
L/R - Rotate unit left or right L/R - rotate unit [L]eft or [R]ight
A - Attack row in front of unit A - [A]ttack in straight line in front of unit
`$ cat README.md | sed 's/^#* //g' | sed 's/\t/\\t/g' | sed ':a;N;$!ba;s/\n/\\n\n/g' | sed 's/^/"/' | sed 's/$/"/' | sed '$ d' > usage.h # To convert this file to c++`

View file

@ -1,56 +0,0 @@
"NAME\n"
"\tttrts - Tiny Terminal RTS\n"
"\n"
"SYNOPSYS\n"
"\tttrts [OPTIONS...] MAPFILE\n"
"\n"
"DESCRIPTION\n"
"\tttrts is a tiny terminal based RTS where that uses text\n"
"\tfiles as order lists to control it's units.\n"
"\n"
"\tThis means that any user, program or cat that can read\n"
"\tand write to text files can play the game.\n"
"\n"
"USAGE\n"
"\tWhen invoked, ttrts will set up a full game and output a\n"
"\tsingle file representing the current gamestate into a \n"
"\tlocal directory called `ttrts_{GAME_NAME}`.\n"
"\n"
"\tThis file can be read in and interpretted by human, robot\n"
"\tor cat. ttrts will wait for orders files to be placed in \n"
"\tit's current working directory.\n"
"\n"
"\tOnce orders have been set for each player taking part \n"
"\tttrts will calculate the new game state and output a new \n"
"\tgamestate file for the next turn.\n"
"\n"
"\tThis process repeats until a winner is chosen!\n"
"\n"
"OPTIONS\n"
"\tMAPFILE - File to read in the initial game state from\n"
"\n"
"-------------------------------------------------------------------------------\n"
"\n"
"GAMESTATE FILE FORMAT\n"
"Name\n"
"\tTurn_{TURN_NUMBER}.txt\n"
"Contents\n"
"\t===== {GAME_NAME} =====\n"
"\tSIZE:[{X},{Y}]\n"
"\tTURN:{TURN_NUMBER}\n"
"\t~~~~\n"
"\tUNIT:{ID} tm:{TEAM} vs:{VIS} dr:{DIR(NESW)} ps:[{X},{Y}]\n"
"\t...\n"
"\n"
"ORDER FILE FORMAT\n"
"Name\n"
"\tTurn_{TURN_NUMBER}_Team_{TEAM_NUMBER}.txt\n"
"Contents\n"
"\tORDER:{ORDER_CHAR} id:{UNIT_ID}\n"
"\t...\n"
"\n"
"Orders\n"
"\tF - Move unit forward one space\n"
"\tL/R - Rotate unit left or right\n"
"\tA - Attack row in front of unit\n"
"\t\n"