Compare commits

...

4 Commits

8 changed files with 72 additions and 13 deletions

View File

@@ -6,11 +6,14 @@ DESTDIR=bin
BUILDDIR=$(CURDIR)/build
MANDIR=$(PREFIX)/share/man/man1
PKGREVISION=1
DEBBUILDDIR=$(BUILDDIR)/deb
DEBTMPLDIR=$(CURDIR)/packaging/debian
DEBDATE=$(shell date -R)
DEBORIGSRC=lume_$(DEBVERSION).orig.tar.xz
DEBORIGSRCDIR=lume-$(DEBVERSION)
DEBREVISION=$(PKGREVISION)
RPMVERSION=$(subst -,_,$(LUME_VERSION))
RPMBUILDDIR=$(BUILDDIR)/rpm
@@ -18,6 +21,7 @@ RPMTMPLDIR=$(CURDIR)/packaging/rpm
RPMDATE=$(shell date "+%a %b %d %Y")
RPMORIGSRC=lume-$(RPMVERSION).tar.xz
RPMORIGSRCDIR=lume-$(RPMVERSION)
RPMREVISION=$(PKGREVISION)
ifeq ($(OS), Windows_NT)
EXE=$(BINDIR)/lume.exe
@@ -60,15 +64,15 @@ install: install-man
$(Q) install -p -D -m 0644 .lumerc.sample $(DESTDIR)${PREFIX}/share/lume/lumerc
.PHONY: deb
deb:
deb: deb-clean
$(Q) mkdir -p $(DEBBUILDDIR)
$(Q) git archive --format tar --prefix lume-$(DEBVERSION)/ $(LUME_VERSION) | xz > $(DEBBUILDDIR)/$(DEBORIGSRC)
$(Q) tar xf $(DEBBUILDDIR)/$(DEBORIGSRC) -C $(DEBBUILDDIR)
$(Q) mkdir $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian
$(Q) mkdir $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/source
$(Q) sed -e 's/__VERSION__/$(DEBVERSION)/g' $(DEBTMPLDIR)/rules > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/rules
$(Q) sed -e 's/__VERSION__/$(DEBVERSION)/g' -e 's/__REVISION__/$(DEBREVISION)/g' $(DEBTMPLDIR)/rules > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/rules
$(Q) chmod 0755 $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/rules
$(Q) sed -e 's/__VERSION__/$(DEBVERSION)/g' -e 's/__DATE__/$(DEBDATE)/g' $(DEBTMPLDIR)/changelog > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/changelog
$(Q) sed -e 's/__VERSION__/$(DEBVERSION)/g' -e 's/__DATE__/$(DEBDATE)/g' -e 's/__REVISION__/$(DEBREVISION)/g' $(DEBTMPLDIR)/changelog > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/changelog
$(Q) echo 10 > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/compat
$(Q) echo "3.0 (quilt)" > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/source/format
$(Q) cp $(DEBTMPLDIR)/control $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/control
@@ -82,10 +86,10 @@ deb:
$(Q) mv $(DEBBUILDDIR)/*.tar.* $(BUILDDIR)
.PHONY: rpm
rpm:
rpm: rpm-clean
$(Q) mkdir -p $(RPMBUILDDIR)/SPECS
$(Q) mkdir -p $(RPMBUILDDIR)/SOURCES
$(Q) sed -e 's/__VERSION__/$(RPMVERSION)/g' -e 's/__DATE__/$(RPMDATE)/g' $(RPMTMPLDIR)/lume.spec > $(RPMBUILDDIR)/SPECS/lume.spec
$(Q) sed -e 's/__VERSION__/$(RPMVERSION)/g' -e 's/__DATE__/$(RPMDATE)/g' -e 's/__REVISION__/$(RPMREVISION)/g' $(RPMTMPLDIR)/lume.spec > $(RPMBUILDDIR)/SPECS/lume.spec
$(Q) git archive --format tar --prefix $(RPMORIGSRCDIR)/ $(LUME_VERSION) | xz > $(RPMBUILDDIR)/SOURCES/$(RPMORIGSRC)
$(Q) rpmbuild --define "_topdir $(RPMBUILDDIR)" -ba $(RPMBUILDDIR)/SPECS/lume.spec
$(Q) mv $(RPMBUILDDIR)/RPMS/*/*.rpm $(BUILDDIR)

View File

@@ -16,7 +16,8 @@ func NewCmdBreathe() Command {
selector := fs.String("selector", defaultSelector, "Set the selector")
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
fs.String("color", defaultColor, "The color to use for the breathe effect")
color := fs.String("color", defaultColor, "The color to use for the breathe effect")
fs.StringVar(color, "c", defaultColor, "The color to use for the breathe effect")
fs.String("from-color", defaultColor, "The color to start the effect from")

View File

@@ -20,6 +20,7 @@ func init() {
RegisterCommand(NewCmdToggle())
RegisterCommand(NewCmdVersion())
RegisterCommand(NewCmdBreathe())
RegisterCommand(NewCmdValidate())
}
var Version string

48
cmd/validate.go Normal file
View File

@@ -0,0 +1,48 @@
package lumecmd
import (
"errors"
"flag"
"fmt"
"git.kill0.net/chill9/lifx-go"
)
func NewCmdValidate() Command {
return Command{
Name: "validate",
Func: ValidateCmd,
Flags: func() *flag.FlagSet {
fs := flag.NewFlagSet("validate", flag.ExitOnError)
return fs
}(),
Use: "<command>",
Short: "Validate a color string",
}
}
func ValidateCmd(ctx Context) (int, error) {
c := ctx.Client
if len(ctx.Args) != 1 {
printCmdHelp(ctx.Name)
return ExitFailure, nil
}
color := lifx.NamedColor(ctx.Args[0])
i, err := c.ValidateColor(color)
if err != nil {
return ExitFailure, err
}
if validColor, ok := i.(*lifx.HSBKColor); ok {
fmt.Print(validColor)
} else {
return ExitFailure, errors.New("go type %T but wanted *HSBKColor")
}
fmt.Println()
return ExitSuccess, nil
}

12
lume.1
View File

@@ -15,7 +15,7 @@
.Bl -tag -width Ds
.It Xo Ic breathe
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Fl Fl color Ns = Ns Ar color
.Fl c | Fl Fl color
.Op Fl Fl from-color Ns = Ns Ar color
.Op Fl Fl cycles Ns = Ns Ar cycles
.Op Fl Fl peak Ns = Ns Ar peak
@@ -35,13 +35,13 @@ List the lights and their basic state
.It Xo Ic poweroff
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Op Fl Fl simple | Fl Fl table
.Op Fl Fl d | Fl Fl duration
.Op Fl d | Fl Fl duration
.Xc
Power off lights
.It Xo Ic poweron
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Op Fl Fl simple | Fl Fl table
.Op Fl Fl d | Fl Fl duration
.Op Fl d | Fl Fl duration
.Xc
Power off lights
.It Xo Ic set-color
@@ -85,11 +85,15 @@ Set light white levels
.Xc
Show extended details about the lights
.It Xo Ic toggle
.Op Fl Fl d | Fl Fl duration
.Op Fl d | Fl Fl duration
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Op Fl Fl simple | Fl Fl table
.Xc
Toggle the power
.It Xo Ic validate
.Ar color_string
.Xc
Validate a color string
.It Xo Ic version
.Xc
Print the version

View File

@@ -1,4 +1,4 @@
lume (__VERSION__) unstable; urgency=medium
lume (__VERSION__-__REVISION__) unstable; urgency=medium
* Package generated with make deb

View File

@@ -2,7 +2,8 @@
DISTRIBUTION = $(shell lsb_release -sr)
VERSION = __VERSION__
PACKAGEVERSION = $(VERSION)
REVISION = __REVISION__
PACKAGEVERSION = $(VERSION)-$(REVISION)
%:
dh $@

View File

@@ -1,6 +1,6 @@
Name: lume
Version: __VERSION__
Release: 1%{?dist}
Release: __REVISION__%{?dist}
Summary: A CLI tool for the LIFX HTTP API
License: MPL