Compare commits
4 Commits
8b232c5ef5
...
23210af0c3
Author | SHA1 | Date | |
---|---|---|---|
23210af0c3
|
|||
8133953bb1
|
|||
8cc556024f
|
|||
c01c342945
|
14
Makefile
14
Makefile
@@ -6,11 +6,14 @@ DESTDIR=bin
|
|||||||
BUILDDIR=$(CURDIR)/build
|
BUILDDIR=$(CURDIR)/build
|
||||||
MANDIR=$(PREFIX)/share/man/man1
|
MANDIR=$(PREFIX)/share/man/man1
|
||||||
|
|
||||||
|
PKGREVISION=1
|
||||||
|
|
||||||
DEBBUILDDIR=$(BUILDDIR)/deb
|
DEBBUILDDIR=$(BUILDDIR)/deb
|
||||||
DEBTMPLDIR=$(CURDIR)/packaging/debian
|
DEBTMPLDIR=$(CURDIR)/packaging/debian
|
||||||
DEBDATE=$(shell date -R)
|
DEBDATE=$(shell date -R)
|
||||||
DEBORIGSRC=lume_$(DEBVERSION).orig.tar.xz
|
DEBORIGSRC=lume_$(DEBVERSION).orig.tar.xz
|
||||||
DEBORIGSRCDIR=lume-$(DEBVERSION)
|
DEBORIGSRCDIR=lume-$(DEBVERSION)
|
||||||
|
DEBREVISION=$(PKGREVISION)
|
||||||
|
|
||||||
RPMVERSION=$(subst -,_,$(LUME_VERSION))
|
RPMVERSION=$(subst -,_,$(LUME_VERSION))
|
||||||
RPMBUILDDIR=$(BUILDDIR)/rpm
|
RPMBUILDDIR=$(BUILDDIR)/rpm
|
||||||
@@ -18,6 +21,7 @@ RPMTMPLDIR=$(CURDIR)/packaging/rpm
|
|||||||
RPMDATE=$(shell date "+%a %b %d %Y")
|
RPMDATE=$(shell date "+%a %b %d %Y")
|
||||||
RPMORIGSRC=lume-$(RPMVERSION).tar.xz
|
RPMORIGSRC=lume-$(RPMVERSION).tar.xz
|
||||||
RPMORIGSRCDIR=lume-$(RPMVERSION)
|
RPMORIGSRCDIR=lume-$(RPMVERSION)
|
||||||
|
RPMREVISION=$(PKGREVISION)
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
EXE=$(BINDIR)/lume.exe
|
EXE=$(BINDIR)/lume.exe
|
||||||
@@ -60,15 +64,15 @@ install: install-man
|
|||||||
$(Q) install -p -D -m 0644 .lumerc.sample $(DESTDIR)${PREFIX}/share/lume/lumerc
|
$(Q) install -p -D -m 0644 .lumerc.sample $(DESTDIR)${PREFIX}/share/lume/lumerc
|
||||||
|
|
||||||
.PHONY: deb
|
.PHONY: deb
|
||||||
deb:
|
deb: deb-clean
|
||||||
$(Q) mkdir -p $(DEBBUILDDIR)
|
$(Q) mkdir -p $(DEBBUILDDIR)
|
||||||
$(Q) git archive --format tar --prefix lume-$(DEBVERSION)/ $(LUME_VERSION) | xz > $(DEBBUILDDIR)/$(DEBORIGSRC)
|
$(Q) git archive --format tar --prefix lume-$(DEBVERSION)/ $(LUME_VERSION) | xz > $(DEBBUILDDIR)/$(DEBORIGSRC)
|
||||||
$(Q) tar xf $(DEBBUILDDIR)/$(DEBORIGSRC) -C $(DEBBUILDDIR)
|
$(Q) tar xf $(DEBBUILDDIR)/$(DEBORIGSRC) -C $(DEBBUILDDIR)
|
||||||
$(Q) mkdir $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian
|
$(Q) mkdir $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian
|
||||||
$(Q) mkdir $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/source
|
$(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) 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 10 > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/compat
|
||||||
$(Q) echo "3.0 (quilt)" > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/source/format
|
$(Q) echo "3.0 (quilt)" > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/source/format
|
||||||
$(Q) cp $(DEBTMPLDIR)/control $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/control
|
$(Q) cp $(DEBTMPLDIR)/control $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/control
|
||||||
@@ -82,10 +86,10 @@ deb:
|
|||||||
$(Q) mv $(DEBBUILDDIR)/*.tar.* $(BUILDDIR)
|
$(Q) mv $(DEBBUILDDIR)/*.tar.* $(BUILDDIR)
|
||||||
|
|
||||||
.PHONY: rpm
|
.PHONY: rpm
|
||||||
rpm:
|
rpm: rpm-clean
|
||||||
$(Q) mkdir -p $(RPMBUILDDIR)/SPECS
|
$(Q) mkdir -p $(RPMBUILDDIR)/SPECS
|
||||||
$(Q) mkdir -p $(RPMBUILDDIR)/SOURCES
|
$(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) git archive --format tar --prefix $(RPMORIGSRCDIR)/ $(LUME_VERSION) | xz > $(RPMBUILDDIR)/SOURCES/$(RPMORIGSRC)
|
||||||
$(Q) rpmbuild --define "_topdir $(RPMBUILDDIR)" -ba $(RPMBUILDDIR)/SPECS/lume.spec
|
$(Q) rpmbuild --define "_topdir $(RPMBUILDDIR)" -ba $(RPMBUILDDIR)/SPECS/lume.spec
|
||||||
$(Q) mv $(RPMBUILDDIR)/RPMS/*/*.rpm $(BUILDDIR)
|
$(Q) mv $(RPMBUILDDIR)/RPMS/*/*.rpm $(BUILDDIR)
|
||||||
|
@@ -16,7 +16,8 @@ func NewCmdBreathe() Command {
|
|||||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||||
fs.StringVar(selector, "s", 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")
|
fs.String("from-color", defaultColor, "The color to start the effect from")
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ func init() {
|
|||||||
RegisterCommand(NewCmdToggle())
|
RegisterCommand(NewCmdToggle())
|
||||||
RegisterCommand(NewCmdVersion())
|
RegisterCommand(NewCmdVersion())
|
||||||
RegisterCommand(NewCmdBreathe())
|
RegisterCommand(NewCmdBreathe())
|
||||||
|
RegisterCommand(NewCmdValidate())
|
||||||
}
|
}
|
||||||
|
|
||||||
var Version string
|
var Version string
|
||||||
|
48
cmd/validate.go
Normal file
48
cmd/validate.go
Normal 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
12
lume.1
@@ -15,7 +15,7 @@
|
|||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Xo Ic breathe
|
.It Xo Ic breathe
|
||||||
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
|
.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 from-color Ns = Ns Ar color
|
||||||
.Op Fl Fl cycles Ns = Ns Ar cycles
|
.Op Fl Fl cycles Ns = Ns Ar cycles
|
||||||
.Op Fl Fl peak Ns = Ns Ar peak
|
.Op Fl Fl peak Ns = Ns Ar peak
|
||||||
@@ -35,13 +35,13 @@ List the lights and their basic state
|
|||||||
.It Xo Ic poweroff
|
.It Xo Ic poweroff
|
||||||
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
|
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
|
||||||
.Op Fl Fl simple | Fl Fl table
|
.Op Fl Fl simple | Fl Fl table
|
||||||
.Op Fl Fl d | Fl Fl duration
|
.Op Fl d | Fl Fl duration
|
||||||
.Xc
|
.Xc
|
||||||
Power off lights
|
Power off lights
|
||||||
.It Xo Ic poweron
|
.It Xo Ic poweron
|
||||||
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
|
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
|
||||||
.Op Fl Fl simple | Fl Fl table
|
.Op Fl Fl simple | Fl Fl table
|
||||||
.Op Fl Fl d | Fl Fl duration
|
.Op Fl d | Fl Fl duration
|
||||||
.Xc
|
.Xc
|
||||||
Power off lights
|
Power off lights
|
||||||
.It Xo Ic set-color
|
.It Xo Ic set-color
|
||||||
@@ -85,11 +85,15 @@ Set light white levels
|
|||||||
.Xc
|
.Xc
|
||||||
Show extended details about the lights
|
Show extended details about the lights
|
||||||
.It Xo Ic toggle
|
.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 s Ar selector | Fl Fl selector Ns = Ns Ar selector
|
||||||
.Op Fl Fl simple | Fl Fl table
|
.Op Fl Fl simple | Fl Fl table
|
||||||
.Xc
|
.Xc
|
||||||
Toggle the power
|
Toggle the power
|
||||||
|
.It Xo Ic validate
|
||||||
|
.Ar color_string
|
||||||
|
.Xc
|
||||||
|
Validate a color string
|
||||||
.It Xo Ic version
|
.It Xo Ic version
|
||||||
.Xc
|
.Xc
|
||||||
Print the version
|
Print the version
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
lume (__VERSION__) unstable; urgency=medium
|
lume (__VERSION__-__REVISION__) unstable; urgency=medium
|
||||||
|
|
||||||
* Package generated with make deb
|
* Package generated with make deb
|
||||||
|
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
DISTRIBUTION = $(shell lsb_release -sr)
|
DISTRIBUTION = $(shell lsb_release -sr)
|
||||||
VERSION = __VERSION__
|
VERSION = __VERSION__
|
||||||
PACKAGEVERSION = $(VERSION)
|
REVISION = __REVISION__
|
||||||
|
PACKAGEVERSION = $(VERSION)-$(REVISION)
|
||||||
|
|
||||||
%:
|
%:
|
||||||
dh $@
|
dh $@
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
Name: lume
|
Name: lume
|
||||||
Version: __VERSION__
|
Version: __VERSION__
|
||||||
Release: 1%{?dist}
|
Release: __REVISION__%{?dist}
|
||||||
Summary: A CLI tool for the LIFX HTTP API
|
Summary: A CLI tool for the LIFX HTTP API
|
||||||
|
|
||||||
License: MPL
|
License: MPL
|
||||||
|
Reference in New Issue
Block a user