Added version command to swaync (#67)

* Added version command to swaync

* Added version arg to client

* Prints to stdout

* Replaced GetServerInformation version with the generated one

* Updated shell completions
This commit is contained in:
Erik Reider
2022-01-27 18:30:53 +01:00
committed by GitHub
parent 5b505ca09b
commit 6e0c9a779a
12 changed files with 52 additions and 11 deletions

View File

@@ -4,12 +4,14 @@ _swaync() {
short=(
-h
-v
-s
-c
)
long=(
--help
--version
--style
--config
)

View File

@@ -4,6 +4,7 @@ _swaync-client() {
short=(
-h
-v
-R
-rs
-t
@@ -20,6 +21,7 @@ _swaync-client() {
long=(
--help
--version
--reload-config
--reload-css
--toggle-panel

View File

@@ -1,5 +1,6 @@
complete -f -c swaync-client
complete -c swaync-client -s h -l help --description "Show help options"
complete -c swaync-client -s v -l version --description "Prints version"
complete -c swaync-client -s R -l reload-config --description "Reload the config file" -r
complete -c swaync-client -s rs -l reload-css --description "Reload the css file. Location change requires restart" -r
complete -c swaync-client -s t -l toggle-panel --description "Toggle the notificaion panel" -r

View File

@@ -1,4 +1,5 @@
complete -f -c swaync
complete -c swaync -s h -l help --description "Show help options"
complete -c swaync -s v -l version --description "Prints version"
complete -c swaync -s s -l style --description "Use a custom Stylesheet file" -r
complete -c swaync -s c -l config --description "Use a custom config file" -r

View File

@@ -2,5 +2,6 @@
_arguments -s \
'(-h --help)'{-h,--help}'[Show help options]' \
'(-v --version)'{-v,--version}'[Prints version]' \
'(-s --style)'{-s,--style}'[Use a custom Stylesheet file]:files:_files' \
'(-c --config)'{-c,--config}'[Use a custom config file]:files:_files' \

View File

@@ -2,6 +2,7 @@
_arguments -s \
'(-h --help)'{-h,--help}'[Show help options]' \
'(-v --version)'{-v,--version}'[Prints version]' \
'(-R --reload-config)'{-R,--reload-config}'[Reload the config file]' \
'(-rs --reload-css)'{-rs,--reload-css}'[Reload the css file. Location change requires restart]' \
'(-t --toggle-panel)'{-t,--toggle-panel}'[Toggle the notificaion panel]' \

View File

@@ -27,6 +27,7 @@ private void print_help (string[] args) {
print (@"\t $(args[0]) <OPTION>\n");
print (@"Help:\n");
print (@"\t -h, \t --help \t\t Show help options\n");
print (@"\t -v, \t --version \t\t Prints version\n");
print (@"Options:\n");
print (@"\t -R, \t --reload-config \t Reload the config file\n");
print (@"\t -rs, \t --reload-css \t\t Reload the css file. Location change requires restart\n");
@@ -66,6 +67,10 @@ public int command_line (string[] args) {
case "-h":
print_help (args);
break;
case "--version":
case "-v":
stdout.printf ("%s\n", Constants.version);
break;
case "--reload-config":
case "-R":
cc_daemon.reload_config ();

View File

@@ -1,4 +0,0 @@
namespace SwayNotificatonCenter {
public class Constants {
}
}

4
src/constants.vala.in Normal file
View File

@@ -0,0 +1,4 @@
public class Constants {
public const string version = @VERSION@;
public const string versionNum = @VERSION_NUM@;
}

View File

@@ -8,10 +8,6 @@ namespace SwayNotificatonCenter {
Hdy.init ();
if (args.length > 0) {
if ("-h" in args || "--help" in args) {
print_help (args);
return;
}
for (uint i = 1; i < args.length; i++) {
string arg = args[i];
switch (arg) {
@@ -23,6 +19,12 @@ namespace SwayNotificatonCenter {
case "--config":
config_path = args[++i];
break;
case "-v":
case "--version":
stdout.printf ("%s\n", Constants.version);
return;
case "-h":
case "--help":
default:
print_help (args);
return;
@@ -66,6 +68,7 @@ namespace SwayNotificatonCenter {
print (@"\t $(args[0]) <OPTION>\n");
print (@"Help:\n");
print (@"\t -h, --help \t\t Show help options\n");
print (@"\t -v, --version \t\t Prints version\n");
print (@"Options:\n");
print (@"\t -s, --style \t\t Use a custom Stylesheet file\n");
print (@"\t -c, --config \t\t Use a custom config file\n");

View File

@@ -1,3 +1,28 @@
# Sets the version to a vala variable in Contants.vala
version = '@0@'.format(meson.project_version())
git = find_program('git', native: true, required: false)
if git.found()
git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'])
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'])
if git_commit.returncode() == 0 and git_branch.returncode() == 0
version = '@0@ (git-@1@, branch \'@2@\')'.format(
meson.project_version(),
git_commit.stdout().strip(),
git_branch.stdout().strip(),
)
endif
endif
version = 'swaync @0@'.format(version)
message('Building version:', version)
const_config_data = configuration_data()
const_config_data.set_quoted('VERSION', version)
const_config_data.set_quoted('VERSION_NUM', meson.project_version())
constants = configure_file(
input : 'constants.vala.in',
output : 'constants.vala',
configuration : const_config_data
)
app_sources = [
'main.vala',
'configModel/configModel.vala',
@@ -8,8 +33,8 @@ app_sources = [
'ccDaemon/ccDaemon.vala',
'controlCenter/controlCenter.vala',
'controlCenter/topAction/topAction.vala',
'constants.vala',
'functions.vala',
constants,
]
app_deps = [
@@ -51,7 +76,7 @@ executable('swaync',
)
executable('swaync-client',
['client.vala', 'constants.vala'],
['client.vala', constants],
vala_args: args,
dependencies: app_deps,
install: true,

View File

@@ -182,7 +182,7 @@ namespace SwayNotificatonCenter {
throws DBusError, IOError {
name = "SwayNotificationCenter";
vendor = "ErikReider";
version = "0.3";
version = Constants.versionNum;
spec_version = "1.2";
}