-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.projuxrc
executable file
·382 lines (367 loc) · 16.2 KB
/
.projuxrc
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
###############################################################################
# Copyright 2012-2018 Mike Dreves
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at:
#
# http://opensource.org/licenses/eclipse-1.0.php
#
# By using this software in any fashion, you are agreeing to be bound
# by the terms of this license. You must not remove this notice, or any
# other, from this software. Unless required by applicable law or agreed
# to in writing, software distributed under the License is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied.
###############################################################################
###############################################################################
# Projux
# -----------------------------------------------------------------------------
#
# See function comments and ~/.projects for examples of features.
#
# Recursive Targets:
# -------------------
# The characters '...' following a directory target means the directory and all
# sub-directores recursively. For example, 'build a/...' means build the
# a/ directory and all its sub-directories.
#
# Keywords:
# -------------------
# By convention, keyword flags are prefixed with ':' (e.g. 'geterrors :build').
#
# Key/Value Maps:
# -------------------
# Some environment variables take a map of key/value settings. The settings are
# specified using the following form:
#
# <key>::<value> <key>::<value> ...
#
# The <key> and <value> settings depend on the type of environment variable.
# There are three main types that use this format:
#
# 1) Project Windows
#
# In this case the <key> is the window name and the <value> is the
# command to use when launching the window. For example to launch bash in
# a 'vim' window and scala in a 'repl' window:
#
# PROJECT_WINDOWS="\
# vim::bash; stty -ixon \ # tmux new-window -d vim 'bash; stty-ixon'
# repl::scala" # tmux new-window -d vim 'scala'
#
# 2) Environment Variables with Commands Per File Type
#
# In this case the <key> is a colon separated list of file extensions and the
# <value> is the command(s) to use on files of those types. For example, for
# the PROJECT_FORMAT_CMDS we could use the following to run clang-format on
# files of type *.{cc,h} and gofmt on files of type *.go, use:
#
# PROJECT_FORMAT_CMDS="\
# cc:h::clang-format -i <targets> \
# go::gofmt -tabs=false -tabwidth=2 -w <targets>"
#
# In this case the keywords <args> will be replaced with the args as passed
# while <target> will be replaced with the expanded targets per file type.
#
# Multiple commands can be run at once by separating them with ';'. For
# example, to run javacheck on *.java and both golint and govet on *.go files:
#
# PROJECT_LINT_CMDS="\
# java::javacheck <targets> \
# go::golint <targets>; govet <targets>"
#
# 3) Environment Variables with Selectable Commands
#
# In this case the <key> represents a name that can be used to select from
# one or more commands. When the associated call is made the key is passed
# and the commmand(s) associated with that key is run. If no key is provided
# then the first command listed is used.
#
# PROJECT_RUN_CMDS="\
# client::client -server=localhost:1234 -data=a,b \
# server::server -port=1234"
#
# $ run client # runs client -server=localhost:1234 -data=a,b
# $ run server # runs server -port=1234
# $ run # runs client -server=localhost:1234 -data=a,b
#
#
# Selectable Commands:
# -------------------
# As mentioned, selectable commands allow you to select from one or more
# commands based on a key:: tag. However, you can also modify the flags that
# are associated with the selected command.
#
# $run server --port=5678 # runs 'server -port=5678'
# $run client --data=+c # runs 'server -port=1234 -data=a,b,c'
# $run client --data=-b,+e # runs 'server -port=1234 -data=a,e'
#
#
# Defaults:
# -------------------
# An environment variable XXX can have a default called DEFAULT_XXX. The
# DEFAULT_XXX value is used when a project does not set a specific XXX value.
# XXX variables are set in ~/.projects while DEFAULT_XXX are set in ~/.bashrc.
#
#
# -----------------------------------------------------------------------------
# Basic Variables:
# -----------------------------------------------------------------------------
# PROJECT_NAME (required)
# Project name.
#
# PROJECT_HOST / DEFAULT_PROJECT_HOST
# Server project should be built/run/etc from (localhost, myserver, etc).
#
# PROJECT_WINDOWS / DEFAULT_PROJECT_WINDOWS
# Map of tmux windows. The keys are window names and the values are
# commands to use when the window is opened (see overview).
# (e.g. "bash::bash; stty -ixon repl::python").
#
# PROJECT_DIR (required)
# Main project directory.
#
# PROJECT_SRC_DIR (required)
# Source directory for project (e.g. $PROJECT_DIR/src).
#
# PROJECT_TEST_DIR (required)
# Test directory for project (e.g. $PROJECT_DIR/test).
#
# PROJECT_TARGET_DIR (required)
# Directory for build (lint/build) output (e.g. $PROJECT_DIR/target).
#
# PROJECT_BIN_DIR (required)
# Directory executable program(s) are output to (e.g.
# $PROJECT_TARGET_DIR/bin). PROJECT_RUN_CMDS are relative to this
# directory.
#
# PROJECT_GEN_DIR (required if cdgen used)
# Directory generated code output to (e.g. $PROJECT_TARGET_DIR/gen).
#
# PROJECT_PKGS (required)
# List of main packages used by project (e.g. "com/example1 com/example2").
# These are directories that should exist in the PROJECT_SRC_DIR and/or
# PROJECT_TEST_DIR. Default is all directories under source and test dirs.
#
# PROJECT_INCLUDE_FILTER / DEFAULT_PROJECT_INCLUDE_FILTER (required)
# Colon separated list of patterns for files that should be considered part
# of the project (for example, make:*.scala:*.java:*.go:*.{c,cc,h}). When
# format, lint, build, test, etc are run, these files are searched for in
# the PROJECT_SRC_DIR and/or PROJECT_TEST_DIR directories. Multiple file
# types may be specified even though only some operations are supported on
# some files (e.g. lint may only be supported for *.java and although
# *.scala may be included in the filter, lint will only be run for java).
# It is best to group files together that go together (e.g. *.{c,cc,h} vs
# *.c:*.cc:*.h). This setting is required.
#
# PROJECT_EXCLUDE_FILTER / DEFAULT_PROJECT_EXCLUDE_FILTER
# Colon separated list of patterns for files that should be NOT be
# considered part of the project (for example, Foo.scala:Bar.java). If these
# files exist in the PROJECT_SRC_DIR or PROJECT_TEST_DIR they will be
# ignored.
#
# PROJECT_BUG
# Current bug ID for work being done in project.
#
# -----------------------------------------------------------------------------
# Variables for Selectable Commands:
# -----------------------------------------------------------------------------
# PROJECT_RUN_CMDS / DEFAULT_PROJECT_RUN_CMDS
# Command(s) to use when run called. A single command can be specified or a
# map of commands can used by labelling them as <key>::<cmd>
# (e.g. clien::client -server=localhost:1234 server::server -port=1234).
#
# PROJECT_CLEAN_CMDS / DEFAULT_PROJECT_CLEAN_CMDS
# Command(s) to use when clean called. A single command can be specified or
# a map of commands can used by labelling them as <key>::<cmd>
# (e.g. sbt clean).
#
# PROJECT_PACKAGE_CMDS / DEFAULT_PROJECT_PACKAGE_CMDS
# Command(s) to use when package called. A single command can be specified
# or a map of commands can used by labelling them as <key>::<cmd>
# (e.g. sbt package).
#
# PROJECT_DEPLOY_CMDS / DEFAULT_PROJECT_DEPLOY_CMDS
# Command(s) to use when deploy called. A single command can be specified or
# a map of commands can used by labelling them as <key>::<cmd>
# (e.g. frontend::ant deploy-fe backend::ant deploy-be).
#
# PROJECT_GENDOCS_CMDS / DEFAULT_PROJECT_GENDOCS_CMDS
# Command(s) to use when gendocs called. A single command can be specified
# or a map of commands can used by labelling them as <key>::<cmd>
# (e.g. scala::sbt doc go::godocs --http=:6060).
#
# PROJECT_SEARCH_CMDS / DEFAUT_PROJECT_SEARCH_CMDS
# Command(s) to use when search called. A single command can be specified
# or a map of commands can used by labelling them as <key>::<cmd>
# (e.g. default::mysearch -src=${PROJECT_SRC_DIR}).
#
# -----------------------------------------------------------------------------
# Variables for Commands Based on File Types:
# -----------------------------------------------------------------------------
# PROJECT_FORMAT_CMDS / DEFAULT_PROJECT_FORMAT_CMDS
# Map of commands to run when formatting project files. The map should
# have the form: <file_ext>:...<file_ext>::<cmd>;...;<cmd> ...
# (e.g. "cc:h::clang-format -i <targets> go::gofmt -w <targets>")
#
# PROJECT_LINT_CMDS / DEFAULT_PROJECT_LINT_CMDS
# Map of commands to run when linting project files. The map should
# have the form: <file_ext>:...<file_ext>::<cmd>;...;<cmd> ...
# (e.g. "cc:h::clint <targets> go::golint <targets>; govet <targets>")
#
# PROJECT_BUILD_CMDS / DEFAULT_PROJECT_BUILD_CMDS
# Map of commands to run when compling project files. The map should
# have the form: <file_ext>:...<file_ext>::<cmd>;...;<cmd> ...
# (e.g. "cc:h::make scala::scalac <targets> java::javac <targets>")
#
# PROJECT_TEST_CMDS / DEFAULT_PROJECT_TEST_CMDS
# Map of commands to run when testing project files. The map should
# have the form: <file_ext>:...<file_ext>::<cmd>;...;<cmd> ...
# (e.g. "scala::sbt test <args>")
#
# PROJECT_COVERAGE_CMDS / DEFAULT_PROJECT_COVERAGE_CMDS
# Map of commands to show code coverage of project tests. The map should
# have the form: <file_ext>:...<file_ext>::<cmd>;...;<cmd>,...
# (e.g. "rb::coverage <args>")
#
# PROJECT_TEST_SUFFIXES / DEFAULT_PROJECT_TEST_SUFFIXES
# Map of suffixes used on test related files. This is used to distinguish
# source and test files when they reside in the same directory. The map
# should have the form: <file_ext>:...<file_ext>::<suffix> ...
# (e.g. "cc::_test")
#
# PROJECT_TEST_TARGETS
# Override for test/coverate include filters. When set
# PROJECT_INCLUDE_FILTER is set to PROJECT_TEST_TARGETS before test or
# coverage is called. When not set, then PROJECT_INCLUDE_FILTER is used as
# set. This is used with the set var :test, etc functions to allow
# configuring a small subset of test to run multiple times during
# development.
#
# -----------------------------------------------------------------------------
# Variables for Custom Implementations:
# -----------------------------------------------------------------------------
# PROJECT_FORMAT_FN / DEFAULT_PROJECT_FORMAT_FN
# Name of custom 'format' function implementation.
#
# PROJECT_LINT_FN / DEFAULT_PROJECT_LINT_FN
# Name of custom 'lint' function implementation.
#
# PROJECT_BUILD_FN / DEFAULT_PROJECT_BUILD_FN
# Name of custom 'build' function implementation.
#
# PROJECT_TEST_FN / DEFAULT_PROJECT_TEST_FN
# Name of custom 'test' function implementation.
#
# PROJECT_COVERAGE_FN / DEFAULT_PROJECT_COVERAGE_FN
# Name of custom 'coverage' function implementation.
#
# PROJECT_GETERRORS_FN / DEFAULT_PROJECT_GETERRORS_FN
# Name of custom 'geterrors' function implementation.
# Errors should be echoed as lines of: <file>:<line>:<col>:<message>.
# See geterrors function for more information.
#
# PROJECT_GETURL_FN / DEFAULT_PROJECT_GETURL_FN
# Name of custom 'geturl' function implementation.
#
# PROJECT_SANITY_FN / DEFAULT_PROJECT_SANITY_FN
# Name of custom 'sanity' function implementation.
#
# -----------------------------------------------------------------------------
# Variables for Sharing/Syncing/Backup:
# -----------------------------------------------------------------------------
# PROJECT_SHARE_DIR / DEFAULT_PROJECT_SHARE_DIR
# This variable is set to the directory to use for copying executables
# for sharing publically (e.g. ~/Public).
#
# PROJECT_BACKUP_DIR / DEFAULT_PROJECT_BACKUP_DIR
# This variable is set to the directory to use for project backups when
# the 'project backup' command is used.
#
# PROJECT_SYNC_LIST / DEFAULT_PROJECT_SYNC_LIST
# This variable is set to the name of a file containing a list of files
# that should be synchronized from the local host to the project host
# when using 'project sync' command. Listed files are specified relative
# to the local home directory. The DEFAULT_PROJECT_SYNC_LIST is by default
# set to ~/.projectsync which contains ~/.projects.
#
# PROJECT_SYNC_DESTS / DEFAULT_PROJECT_SYNC_DESTS
# Comma separated list of directories to sync files to on remote host.
#
# -----------------------------------------------------------------------------
# Misc Variables:
# -----------------------------------------------------------------------------
# PROJUX_ALIASES
# Set to true to add projux related aliases (cdsrc, etc).
#
# PROXY_CMDS
# Set to true to proxy commands to remote host when running locally.
#
# PROJUX_NOTIFY_FN
# A function to call whenever a tmux new, attach, or switch call is made.
# The first parameter will be true if the call is for 'new'.
#
# VERBOSE
# Some commands take a VERBOSE environment variable. This is a level setting
# not on/off. Level 0 effectively means off which is different than most
# flags in bash where 0 is success). Many commands do not support verbose
# output yet, so don't expect much.
#
# HEADING
# Whether to print a heading when VERBOSE is used. This is a true/false
# settings (e.g. DRY_RUN=true).
#
# DRY_RUN
# The dry run flag will print the command that will execute, but not
# actualy execute it. This is a true/false settings (e.g. DRY_RUN=true).
#
# -----------------------------------------------------------------------------
# Common local (per command) Variables/Flags:
# -----------------------------------------------------------------------------
# -p <project>[:<win>]
# Some commands accept a -p flag to specify the project to run the command
# against. If used, this must come before other cmd args. When used the
# current project will not be changed, instead the command will be sent over
# tmux to the project window specified with :<win> (or the first window if
# :<win> not specified).
################################################################################
################################################################################
# Default Variables
################################################################################
if [[ -z "${DEFAULT_PROJECT_HOST}" ]]; then
DEFAULT_PROJECT_HOST=$(hostname) # Use local project host if not set
fi
if [[ -z "${DEFAULT_PROJECT_WINDOWS}" ]]; then
DEFAULT_PROJECT_WINDOWS="\
vim::bash; stty -ixon \
build::bash; stty -ixon"
fi
if [[ -z "${DEFAULT_PROJECT_SHARE_DIR}" ]]; then
DEFAULT_PROJECT_SHARE_DIR="~/Public"
fi
if [[ -z "${DEFAULT_PROJECT_BACKUP_DIR}" ]]; then
DEFAULT_PROJECT_BACKUP_DIR="~/backups"
fi
if [[ -z "${DEFAULT_PROJECT_SYNC_LIST}" ]]; then
DEFAULT_PROJECT_SYNC_LIST="${HOME}/.projectsync"
fi
if [[ -z "${DEFAULT_PROJECT_SYNC_DESTS}" ]]; then
DEFAULT_PROJECT_SYNC_DESTS="~"
fi
PROJUX_SCRIPT_DIR="$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)"
################################################################################
# Commands
################################################################################
. ${PROJUX_SCRIPT_DIR}/.projux_cmds
################################################################################
# Aliases
################################################################################
if [[ ${PROJUX_ALIASES-true} -eq 0 ]]; then
. ${PROJUX_SCRIPT_DIR}/.projux_aliases
fi
################################################################################
# Init
################################################################################
# Initialize with current project (no-op if no project set)
__projux_project_init $(__projux_cur_project)