Compare commits

...

7 Commits

Author SHA1 Message Date
8b232c5ef5
Add man page to packages
Refs #6
2021-04-15 02:01:28 +00:00
d6ca2d7921
Install man page
Refs #6
2021-04-15 01:54:18 +00:00
f79de85d43
Add a man page
Refs #6
2021-04-15 01:41:52 +00:00
05f445ddf2
Make output format flags boolean 2021-04-11 02:39:58 +00:00
baf7daa1bb
Remove unused compat file 2021-04-10 07:25:00 +00:00
43b0c0a399
Add copyright to Debian package 2021-04-10 07:23:57 +00:00
7ac2cab082
Fix Debian package warnings 2021-04-10 07:23:25 +00:00
17 changed files with 283 additions and 15 deletions

View File

@ -4,6 +4,7 @@ BINDIR=$(CURDIR)/bin
PREFIX=/usr
DESTDIR=bin
BUILDDIR=$(CURDIR)/build
MANDIR=$(PREFIX)/share/man/man1
DEBBUILDDIR=$(BUILDDIR)/deb
DEBTMPLDIR=$(CURDIR)/packaging/debian
@ -50,8 +51,11 @@ build:
clean: deb-clean rpm-clean
$(Q) $(RM) $(EXE)
install-man:
install -p -D -m 0644 lume.1 $(DESTDIR)$(MANDIR)/lume.1
.PHONY: install
install:
install: install-man
$(Q) install -p -D -m 0755 $(EXE) $(DESTDIR)${PREFIX}/bin/lume
$(Q) install -p -D -m 0644 .lumerc.sample $(DESTDIR)${PREFIX}/share/lume/lumerc
@ -61,10 +65,15 @@ deb:
$(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) 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) echo 9 > $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/compat
$(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
$(Q) cp $(DEBTMPLDIR)/copyright $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/copyright
$(Q) cp $(DEBTMPLDIR)/lume.manpages $(DEBBUILDDIR)/$(DEBORIGSRCDIR)/debian/lume.manpages
$(Q) cd $(DEBBUILDDIR)/$(DEBORIGSRCDIR) && dpkg-buildpackage -us -uc
$(Q) mv $(DEBBUILDDIR)/*.dsc $(BUILDDIR)
$(Q) mv $(DEBBUILDDIR)/*.changes $(BUILDDIR)

View File

@ -43,7 +43,10 @@ func BreatheCmd(ctx Context) (int, error) {
c := ctx.Client
breathe := lifx.NewBreathe()
selector := ctx.Flags.String("selector")
format := ctx.Flags.String("output-format")
format, err := getOutputFormatFromFlags(ctx.Flags)
if err != nil {
return ExitFailure, err
}
if format == "" && ctx.Config.OutputFormat != "" {
format = ctx.Config.OutputFormat

View File

@ -1,6 +1,7 @@
package lumecmd
import (
"errors"
"flag"
"fmt"
"strconv"
@ -100,6 +101,22 @@ func GetCommand(name string) (Command, bool) {
func mergeGlobalFlags(fs *flag.FlagSet) {
fs.Bool("debug", false, "Enable debug mode")
outputFormat := fs.String("output-format", defaultOutputFormat, "Set the output format")
fs.StringVar(outputFormat, "o", defaultOutputFormat, "Set the output format")
formatTable := fs.Bool("table", false, "Format output as an ASCII table")
fs.BoolVar(formatTable, "t", false, "Format output as an ASCII table")
fs.Bool("simple", false, "Format output simply")
}
func getOutputFormatFromFlags(fs Flags) (string, error) {
formatSimple := fs.Bool("simple")
formatTable := fs.Bool("table")
switch {
case formatSimple && formatTable:
return "", errors.New("only one output format permitted")
case formatTable:
return "table", nil
default:
return "simple", nil
}
}

View File

@ -26,7 +26,10 @@ func LsCmd(ctx Context) (int, error) {
c := ctx.Client
selector := ctx.Flags.String("selector")
format := ctx.Flags.String("output-format")
format, err := getOutputFormatFromFlags(ctx.Flags)
if err != nil {
return ExitFailure, err
}
if format == "" && ctx.Config.OutputFormat != "" {
format = ctx.Config.OutputFormat

View File

@ -32,8 +32,11 @@ func PoweroffCmd(ctx Context) (int, error) {
c := ctx.Client
duration := ctx.Flags.Float64("duration")
selector := ctx.Flags.String("selector")
format := ctx.Flags.String("output-format")
state := lifx.State{Power: "off", Duration: duration}
format, err := getOutputFormatFromFlags(ctx.Flags)
if err != nil {
return ExitFailure, err
}
if format == "" && ctx.Config.OutputFormat != "" {
format = ctx.Config.OutputFormat

View File

@ -32,8 +32,11 @@ func PoweronCmd(ctx Context) (int, error) {
c := ctx.Client
duration := ctx.Flags.Float64("duration")
selector := ctx.Flags.String("selector")
format := ctx.Flags.String("output-format")
state := lifx.State{Power: "on", Duration: duration}
format, err := getOutputFormatFromFlags(ctx.Flags)
if err != nil {
return ExitFailure, err
}
if format == "" && ctx.Config.OutputFormat != "" {
format = ctx.Config.OutputFormat

View File

@ -54,7 +54,10 @@ func SetColorCmd(ctx Context) (int, error) {
c := ctx.Client
state := lifx.State{}
selector := ctx.Flags.String("selector")
format := ctx.Flags.String("output-format")
format, err := getOutputFormatFromFlags(ctx.Flags)
if err != nil {
return ExitFailure, err
}
if format == "" && ctx.Config.OutputFormat != "" {
format = ctx.Config.OutputFormat

View File

@ -47,7 +47,10 @@ func SetStateCmd(ctx Context) (int, error) {
c := ctx.Client
state := lifx.State{}
selector := ctx.Flags.String("selector")
format := ctx.Flags.String("output-format")
format, err := getOutputFormatFromFlags(ctx.Flags)
if err != nil {
return ExitFailure, err
}
if format == "" && ctx.Config.OutputFormat != "" {
format = ctx.Config.OutputFormat

View File

@ -50,7 +50,10 @@ func SetWhiteCmd(ctx Context) (int, error) {
c := ctx.Client
state := lifx.State{}
selector := ctx.Flags.String("selector")
format := ctx.Flags.String("output-format")
format, err := getOutputFormatFromFlags(ctx.Flags)
if err != nil {
return ExitFailure, err
}
if format == "" && ctx.Config.OutputFormat != "" {
format = ctx.Config.OutputFormat

View File

@ -30,7 +30,10 @@ func ToggleCmd(ctx Context) (int, error) {
c := ctx.Client
duration := ctx.Flags.Float64("duration")
selector := ctx.Flags.String("selector")
format := ctx.Flags.String("output-format")
format, err := getOutputFormatFromFlags(ctx.Flags)
if err != nil {
return ExitFailure, err
}
if format == "" && ctx.Config.OutputFormat != "" {
format = ctx.Config.OutputFormat

182
lume.1 Normal file
View File

@ -0,0 +1,182 @@
.Dd $Mdocdate$
.Dt lume \&1 "User Commands"
.Sh NAME
.Nm lume
.Nd CLI tool for the LIFX HTTP API
.Sh SYNOPSIS
.Nm lume
.Ar COMMAND
.Op Ar OPTIONS ...
.Sh COMMANDS
.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
.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
.Op Fl Fl period Ns = Ns Ar period
.Op Fl Fl persist
.Op Fl Fl power-on
.Xc
.It Xo Ic help
.Op Ar COMMAND
.Xc
Print the help message. If a command is specified, then show the subcommand's help message.
.It Xo Ic ls
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Op Fl Fl simple | Fl Fl table
.Xc
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
.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
.Xc
Power off lights
.It Xo Ic set-color
.Op Fl b Ar brightness | Fl Fl brightness Ns = Ns Ar brightness
.Op Fl d | Fl Fl duration
.Op Fl f Ar fast | Fl Fl fast Ns = Ns Ar fast
.Op Fl H Ar hue | Fl Fl hue Ns = Ns Ar hue
.Op Fl n Ar name | Fl Fl name Ns = Ns Ar name
.Op Fl p Ar power | Fl Fl power Ns = Ns Ar power
.Op Fl r Ar rgb | Fl Fl rgb Ns = Ns Ar rgb
.Op Fl S Ar saturation | Fl Fl saturation Ns = Ns Ar saturation
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Op Fl Fl simple | Fl Fl table
.Xc
Set light color
.It Xo Ic set-state
.Op Fl b Ar brightness | Fl Fl brightness Ns = Ns Ar brightness
.Op Fl c | Fl Fl color
.Op Fl d | Fl Fl duration
.Op Fl f Ar fast | Fl Fl fast Ns = Ns Ar fast
.Op Fl i Ar infrared | Fl Fl infrared Ns = Ns Ar infrared
.Op Fl p Ar power | Fl Fl power Ns = Ns Ar power
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Op Fl Fl simple | Fl Fl table
.Xc
Set light properties
.It Xo Ic set-white
.Op Fl b Ar brightness | Fl Fl brightness Ns = Ns Ar brightness
.Op Fl d | Fl Fl duration
.Op Fl f Ar fast | Fl Fl fast Ns = Ns Ar fast
.Op Fl i Ar infrared | Fl Fl infrared Ns = Ns Ar infrared
.Op Fl k Ar kelvin | Fl Fl kelvin Ns = Ns Ar kelvin
.Op Fl n Ar name | Fl Fl name Ns = Ns Ar name
.Op Fl p Ar power | Fl Fl power Ns = Ns Ar power
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Op Fl Fl simple | Fl Fl table
.Xc
Set light white levels
.It Xo Ic show
.Op Fl s Ar selector | Fl Fl selector Ns = Ns Ar selector
.Xc
Show extended details about the lights
.It Xo Ic toggle
.Op Fl 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 version
.Xc
Print the version
.El
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl b , Fl Fl brightness Ns = Ns Ar brightness
The brightness level from 0.0 to 1.0. Overrides any brightness set in color (if any)
.It Fl c , Fl Fl color Ns = Ns Ar color
This color to use for the action.
.Pp
When used with the
.Nm breathe
effect, this
is the "to" color.
.It Fl Fl cycles Ns = Ns Ar cycles
The number of times to repeat the effect. Defaults to 1.0 cycle.
.It Fl d , Fl Fl duration Ns = Ns Ar duration
The time in seconds to spend performing the action. Range: 0.0 3155760000.0 (100 years).
.It Fl f , Fl Fl fast
Execute the action fast without any state checks or waiting for the result from the HTTP API
.It Fl Fl from-color Ns = Ns Ar color
The color to start the
.Nm breathe
effect from. If this parameter is omitted
then the color the bulb is currently set to is used instead.
.It Fl H , Fl Fl hue Ns = Ns Ar hue
Sets the hue. Range 0 - 360.
.It Fl i , Fl Fl infrared Ns = Ns Ar infrared
Sets the maximum brightness of the infrared channel from 0.0 to 1.0.
.It Fl k , Fl Fl kelvin Ns = Ns Ar kelvin
Set the kelvin value. The saturation is automatically set to 0.
.It Fl n , Fl Fl name Ns = Ns Ar name
Set the color using a named color from
.Pa lumerc
.It Fl Fl peak Ns = Ns Ar peak
Defines where in a period the target color is at its maximum. Minimum 0.0,
maximum 1.0. Defaults to 0.5.
.It Fl Fl period Ns = Ns Ar period
The time in seconds for one cycle of the
.Nm breathe
effect. Defaults to 1.0
second.
.It Fl Fl persist
If false set the light back to its previous value when effect ends, if true
leave the last effect color.
.It Fl p , Fl Fl power Ns = Ns Ar [ on | off ]
Set the power state
.It Fl Fl power-on
If true, turn the bulb on if it is not already on.
.It Fl r , Fl Fl rgb Ns = Ns Ar R,G,B
Set the color via a comma delimited R,G,B string. Values range from 0 - 255.
.It Fl S , Fl Fl saturation Ns = Ns Ar saturation
Set the saturation. Range 0.0 - 1.0.
.It Fl s , Fl Fl selector Ns = Ns Ar selector
The selector is used to group lights together belonging in the same account
.Pp
Selectors can be in the following format: all, label:[value], id:[value], group_id:[value], group:[value], location_id:[value], location:[value], scene_id:[value]
.Pp
The default selector is "all"
.Sh FILES
.Bl -tag -width "~/.config/lume/lume.conf" -compact
.It Pa ~/.lumerc
Default
.Nm
configuration file
.It Pa ~/.config/lume/lume.conf
XDG config home
.Nm
configuration file
.Sh EXAMPLES
Sample
.Pa lumerc
file:
.Bd -literal -offset indent
access_token = "token"
# indicator = "●"
# output_format = "table"
[colors]
purple_candy = [ 280.0, 0.29, 0.71 ]
wasabi = [ 120.0, 1.0, 0.7 ]
honeydew = [ 120.0, 1.0, 0.97 ]
green_mist = [ 92.0, 0.72, 0.75 ]
pea = [ 90.0, 0.42, 0.47 ]
cat_eye = [ 76.0, 0.74, 0.61 ]
seagreen = [ 160.0, 1.0, 0.50 ]
blue_mist = [ 202.0, 0.97, 0.75 ]
.Ed

View File

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

View File

@ -1 +0,0 @@
9

View File

@ -1,7 +1,14 @@
Source: lume
Section: unknown
Priority: optional
Maintainer: Ryan Cavicchioni <ryan@cavi.cc>
Build-Depends: debhelper (>= 10)
Standards-Version: 4.1.2
Homepage: https://git.kill0.net/chill9/lume
Vcs-Git: https://git.kill0.net/chill9/lume.git
Vcs-Browser: https://git.kill0.net/chill9/lume.git
Package: lume
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: A CLI tool for the LIFX HTTP API

View File

@ -0,0 +1,28 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: lume
Source: https://git.kill0.net/chill9/lume
Files: *
Copyright: 2021 Ryan Cavicchioni <ryan@cavi.cc>
License: MPL-2.0
License: MPL-2.0
Licensed under the Mozilla Public License License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may
obtain a copy of the License at
.
https://www.mozilla.org/en-US/MPL/2.0/
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
On Debian systems, the complete text of the Mozilla Public License version 2.0
license can be found in "/usr/share/common-licenses/MPL-2.0".
# Please also look if there are files or directories which have a
# different copyright/license attached and list them here.
# Please avoid picking licenses with terms that are more restrictive than the
# packaged work, as it may make Debian's contributions unacceptable upstream.

View File

@ -0,0 +1 @@
lume.1

View File

@ -25,6 +25,7 @@ Source: %{name}-%{version}.tar.xz
%{_bindir}/lume
%license LICENSE
/usr/share/lume/lumerc
%doc %{_mandir}/man1/lume.1.*
%changelog