versioning

This commit is contained in:
skilion 2017-07-14 11:31:16 +02:00
parent 849dd36276
commit 7fae9c1bef
5 changed files with 52 additions and 29 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
.*
onedrive
onedrive.o
onedrive.service
version

8
CHANGELOG.md Normal file
View file

@ -0,0 +1,8 @@
# Changelog
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [1.0.0] - 2017-07-14
### Added
* `--version` option

View file

@ -1,4 +1,4 @@
DFLAGS = -ofonedrive -L-lcurl -L-lsqlite3 -L-ldl
DFLAGS = -ofonedrive -L-lcurl -L-lsqlite3 -L-ldl -J.
PREFIX = /usr/local
SOURCES = \
@ -17,25 +17,28 @@ SOURCES = \
all: onedrive onedrive.service
onedrive: $(SOURCES)
dmd -g -inline -O -release $(DFLAGS) $(SOURCES)
onedrive.service:
sed "s|@PREFIX@|$(PREFIX)|g" onedrive.service.in > onedrive.service
debug: $(SOURCES)
dmd -debug -g -gs $(DFLAGS) $(SOURCES)
unittest: $(SOURCES)
dmd -debug -g -gs -unittest $(DFLAGS) $(SOURCES)
clean:
rm -f onedrive onedrive.o onedrive.service
debug: version $(SOURCES)
dmd -debug -g -gs $(DFLAGS) $(SOURCES)
install: all
install -D onedrive $(DESTDIR)$(PREFIX)/bin/onedrive
install -D -m 644 onedrive.service $(DESTDIR)/usr/lib/systemd/user/onedrive.service
onedrive: version $(SOURCES)
dmd -g -inline -O -release $(DFLAGS) $(SOURCES)
onedrive.service:
sed "s|@PREFIX@|$(PREFIX)|g" onedrive.service.in > onedrive.service
unittest: $(SOURCES)
dmd -debug -g -gs -unittest $(DFLAGS) $(SOURCES)
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/onedrive
rm -f $(DESTDIR)/usr/lib/systemd/user/onedrive.service
version: .git/HEAD .git/index
printf "$(shell git describe --tags 2>/dev/null)" >version

View file

@ -121,13 +121,14 @@ If you encounter any bugs you can report them here on Github. Before filing an i
```text
Usage: onedrive [OPTION]...
no option Sync and exit.
-m --monitor Keep monitoring for local and remote changes.
--resync Forget the last saved state, perform a full sync.
--logout Logout the current user.
--confdir Set the directory to use to store the configuration files.
-v --verbose Print more details, useful for debugging.
--print-token Print the access token, useful for debugging.
no option Sync and exit
--confdir Set the directory used to store the configuration files
--logout Logout the current user
-m --monitor Keep monitoring for local and remote changes
--print-token Print the access token, useful for debugging
--resync Forget the last saved state, perform a full sync
-v --verbose Print more details, useful for debugging
--version Print the version and exit
-h --help This help information.
```

View file

@ -1,6 +1,6 @@
import core.stdc.stdlib: EXIT_SUCCESS, EXIT_FAILURE;
import core.memory, core.time, core.thread;
import std.getopt, std.file, std.path, std.process;
import std.getopt, std.file, std.path, std.process, std.stdio;
import config, itemdb, monitor, onedrive, selective, sync, util;
static import log;
@ -18,32 +18,41 @@ int main(string[] args)
bool verbose;
// print the access token
bool printAccessToken;
// print the version and exit
bool printVersion;
try {
auto opt = getopt(
args,
std.getopt.config.bundling,
"monitor|m", "Keep monitoring for local and remote changes.", &monitor,
"resync", "Forget the last saved state, perform a full sync.", &resync,
"logout", "Logout the current user.", &logout,
"confdir", "Set the directory to use to store the configuration files.", &configDirName,
"verbose|v", "Print more details, useful for debugging.", &log.verbose,
"print-token", "Print the access token, useful for debugging.", &printAccessToken
std.getopt.config.caseSensitive,
"confdir", "Set the directory used to store the configuration files", &configDirName,
"logout", "Logout the current user", &logout,
"monitor|m", "Keep monitoring for local and remote changes", &monitor,
"print-token", "Print the access token, useful for debugging", &printAccessToken,
"resync", "Forget the last saved state, perform a full sync", &resync,
"verbose|v", "Print more details, useful for debugging", &log.verbose,
"version", "Print the version and exit", &printVersion
);
if (opt.helpWanted) {
defaultGetoptPrinter(
"Usage: onedrive [OPTION]...\n\n" ~
"no option Sync and exit.",
"no option Sync and exit",
opt.options
);
return EXIT_SUCCESS;
}
} catch (GetOptException e) {
log.log(e.msg);
log.log("Try 'onedrive -h' for more information.");
log.log("Try 'onedrive -h' for more information");
return EXIT_FAILURE;
}
if (printVersion) {
writeln("OneDrive Free Client version ", import("version"));
return EXIT_SUCCESS;
}
log.vlog("Loading config ...");
configDirName = configDirName.expandTilde().absolutePath();
if (!exists(configDirName)) mkdir(configDirName);