From 7fae9c1befb618d97e7366fd20de2c04e91b99b0 Mon Sep 17 00:00:00 2001 From: skilion Date: Fri, 14 Jul 2017 11:31:16 +0200 Subject: [PATCH] versioning --- .gitignore | 2 ++ CHANGELOG.md | 8 ++++++++ Makefile | 29 ++++++++++++++++------------- README.md | 15 ++++++++------- src/main.d | 27 ++++++++++++++++++--------- 5 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.gitignore b/.gitignore index 20d75218..d8847e28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .* onedrive onedrive.o +onedrive.service +version diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..bcaf3f53 --- /dev/null +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index f6286df6..6405f2c9 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 88c01a00..f36b68a7 100644 --- a/README.md +++ b/README.md @@ -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. ``` diff --git a/src/main.d b/src/main.d index 087f19ba..ac3f2189 100644 --- a/src/main.d +++ b/src/main.d @@ -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);