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
onedrive.o 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 PREFIX = /usr/local
SOURCES = \ SOURCES = \
@ -17,25 +17,28 @@ SOURCES = \
all: onedrive onedrive.service 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: clean:
rm -f onedrive onedrive.o onedrive.service rm -f onedrive onedrive.o onedrive.service
debug: version $(SOURCES)
dmd -debug -g -gs $(DFLAGS) $(SOURCES)
install: all install: all
install -D onedrive $(DESTDIR)$(PREFIX)/bin/onedrive install -D onedrive $(DESTDIR)$(PREFIX)/bin/onedrive
install -D -m 644 onedrive.service $(DESTDIR)/usr/lib/systemd/user/onedrive.service 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: uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/onedrive rm -f $(DESTDIR)$(PREFIX)/bin/onedrive
rm -f $(DESTDIR)/usr/lib/systemd/user/onedrive.service 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 ```text
Usage: onedrive [OPTION]... Usage: onedrive [OPTION]...
no option Sync and exit. no option Sync and exit
-m --monitor Keep monitoring for local and remote changes. --confdir Set the directory used to store the configuration files
--resync Forget the last saved state, perform a full sync. --logout Logout the current user
--logout Logout the current user. -m --monitor Keep monitoring for local and remote changes
--confdir Set the directory to use to store the configuration files. --print-token Print the access token, useful for debugging
-v --verbose Print more details, useful for debugging. --resync Forget the last saved state, perform a full sync
--print-token Print the access token, useful for debugging. -v --verbose Print more details, useful for debugging
--version Print the version and exit
-h --help This help information. -h --help This help information.
``` ```

View file

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