-
Notifications
You must be signed in to change notification settings - Fork 0
/
banias
executable file
·143 lines (119 loc) · 4.65 KB
/
banias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env sh
# This file is part of banias. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/raphaelcohn/banias/master/COPYRIGHT. No part of banias, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2015 The developers of banias. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/raphaelcohn/banias/master/COPYRIGHT.
_program()
{
core_usesIn banias dependencies validate reports templates
banias()
{
banias_dependencies_populateUname
banias_dependencies_checkForPresenceOfLatex
banias_validate_populatePotentialReportsIfNonOptionsEmpty
banias_reports_makeReportsPathAbsolute
banias_validate_populateReportsCheckingTheyAreValid
banias_reports_createOutputPathAndMakeItAbsolute
banias_reports_createTemporaryFileToConcatenateMarkdownTo
banias_templates_initialise
banias_reports_registerConfiguration
banias_reports_create
}
}
_program_name='banias'
_program_version='unversioned'
_program_package_or_build=''
_program_path="$([ "${_program_fattening_program_path+set}" = 'set' ] && printf '%s\n' "$_program_fattening_program_path" || ([ "${0%/*}" = "${0}" ] && printf '%s\n' '.' || printf '%s\n' "${0%/*}"))"
_program_libPath="${_program_path}/lib"
_program_etcPath="${_program_path}/etc"
_program_varPath="${_program_path}/var"
_program_entrypoint='banias'
_program_commandLine_parseInitialise()
{
banias_reportsPath_default="$(pwd)"
banias_outputPath_default="$banias_reportsPath_default"
banias_format_default='pdf'
}
_program_commandLine_helpMessage()
{
_program_commandLine_helpMessage_usage="[OPTION]... -- [REPORTs]...
"
_program_commandLine_helpMessage_description="Creates PDF REPORTs from markdown fragments stored in Git; reports are folders"
_program_commandLine_helpMessage_options="
-r, --reports-path PATH PATH to reports folder.
Defaults to '$banias_reportsPath_default'.
-o, --output-path PATH PATH to folder of output.
Defaults to '$banias_outputPath_default'.
-f, --format FORMAT FORMAT (one of pdf or latex)
Defaults to '$banias_format_default'.
If REPORTs are unspecified, all reports are used"
_program_commandLine_helpMessage_optionsSpacing=' '
_program_commandLine_helpMessage_configurationKeys="
banias_reportsPath Equivalent to --reports-path
banias_outputPath Equivalent to --output-path
banias_format Equivalent to --format
"
_program_commandLine_helpMessage_examples="
${_program_name} my-report
"
}
_program_commandLine_optionExists()
{
case "$optionName" in
o|output-path)
echo 'yes-argumented'
;;
r|reports-path)
echo 'yes-argumented'
;;
f|format)
echo 'yes-argumented'
;;
*)
echo 'no'
;;
esac
}
_program_commandLine_processOptionWithoutArgument()
{
:
}
_program_commandLine_processOptionWithArgument()
{
case "$optionName" in
o|output-path)
core_validate_folderPathIsReadableAndSearchableAndWritableOrCanBeCreated $core_commandLine_exitCode_USAGE 'option' "$optionNameIncludingHyphens" "$optionValue"
banias_outputPath="$optionValue"
;;
r|reports-path)
core_validate_folderPathReadableAndSearchable $core_commandLine_exitCode_USAGE 'option' "$optionNameIncludingHyphens" "$optionValue"
banias_reportsPath="$optionValue"
;;
f|format)
banias_validate_format $core_commandLine_exitCode_USAGE 'option' "$optionNameIncludingHyphens" "$optionValue"
banias_format="$optionValue"
;;
esac
}
_program_commandLine_handleNonOptions()
{
core_variable_array_initialise banias_potentialReports
core_variable_array_append banias_potentialReports "$@"
}
_program_commandLine_validate()
{
if core_variable_isUnset banias_reportsPath; then
banias_reportsPath="$banias_reportsPath_default"
else
core_validate_folderPathReadableAndSearchable $core_commandLine_exitCode_CONFIG 'configuration setting' 'banias_reportsPath' "$banias_reportsPath"
fi
if core_variable_isUnset banias_outputPath; then
banias_outputPath="$banias_outputPath_default"
else
core_validate_folderPathIsReadableAndSearchableAndWritableOrCanBeCreated $core_commandLine_exitCode_CONFIG 'configuration setting' 'banias_outputPath' "$banias_outputPath"
fi
if core_variable_isUnset banias_format; then
banias_format="$banias_format_default"
else
banias_validate_format $core_commandLine_exitCode_CONFIG 'configuration setting' 'banias_format' "$banias_format"
fi
}
. "$_program_libPath"/shellfire/core/init.functions "$@"