diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2011-05-16 19:57:39 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2011-05-16 19:57:39 -0700 |
commit | 76ff750a6b057dacba1361726f15cd5bd4bfe14b (patch) | |
tree | 8eea69cfa6ba3377883d2caa4aeca874c100b2a3 /src/cli_shell_api.cpp | |
parent | 7ea935bc47f37111b95ed8a4f989a2ae3f578e5a (diff) | |
download | vyatta-cfg-76ff750a6b057dacba1361726f15cd5bd4bfe14b.tar.gz vyatta-cfg-76ff750a6b057dacba1361726f15cd5bd4bfe14b.zip |
reimplement commit hooks mechanism
* do NOT reinvent the wheel (directory traversal, sorting, script execution, etc.) when the functionality is already provided by the system.
* eliminate hard-coded hook directory in various feastures. everyone should obtain the directory path from the config backend.
Diffstat (limited to 'src/cli_shell_api.cpp')
-rw-r--r-- | src/cli_shell_api.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cli_shell_api.cpp b/src/cli_shell_api.cpp index 6e8f384..0caccb9 100644 --- a/src/cli_shell_api.cpp +++ b/src/cli_shell_api.cpp @@ -486,6 +486,26 @@ _cf_process_args(Cstore& cstore, const Cpath& args, Cpath& path) return root; } +// output the "pre-commit hook dir" +static void +getPreCommitHookDir(Cstore& cstore, const Cpath& args) +{ + const char *d = commit::getCommitHookDir(commit::PRE_COMMIT); + if (d) { + printf("%s", d); + } +} + +// output the "post-commit hook dir" +static void +getPostCommitHookDir(Cstore& cstore, const Cpath& args) +{ + const char *d = commit::getCommitHookDir(commit::POST_COMMIT); + if (d) { + printf("%s", d); + } +} + /* the following "cf" functions form the "config file" shell API, which * allows shell scripts to "query" the "config" represented by a config * file in a way similar to how they query the active/working config. @@ -574,6 +594,9 @@ static OpT ops[] = { OP(showConfig, -1, NULL, -1, NULL, true), OP(loadFile, 1, "Must specify config file", -1, NULL, false), + OP(getPreCommitHookDir, 0, "No argument expected", -1, NULL, false), + OP(getPostCommitHookDir, 0, "No argument expected", -1, NULL, false), + OP(cfExists, -1, NULL, 2, "Must specify config file and path", false), OP(cfReturnValue, -1, NULL, 2, "Must specify config file and path", false), OP(cfReturnValues, -1, NULL, 2, "Must specify config file and path", false), |