Skip to content

Commit

Permalink
Remove experimental set feature
Browse files Browse the repository at this point in the history
Move experimental set feature into `thrid_party`.

Add version sub-command.
  • Loading branch information
HeavyWombat committed Nov 1, 2018
1 parent 12265c7 commit 820734e
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 114 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
internal/**/updateYAML.c
internal/**/updateYAML.go
internal/**/__pycache__
binaries
third_party
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ go:

os:
- linux
- osx

install:
- if [[ "$(uname)" == "Linux" ]]; then sudo apt-get update >/dev/null && sudo apt-get install -y build-essential libssl-dev libffi-dev zlib1g-dev; fi
- if [[ "$(uname)" == "Darwin" ]]; then brew update >/dev/null && brew install jq && ( brew outdated openssl || brew upgrade openssl ); fi
- curl --silent --location https://goo.gl/g1CpPX | bash -s v1.0.2

script:
Expand Down
43 changes: 14 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,30 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

.PHONY: all clean mrproper test pythontest gotest build upx
.PHONY: all clean test gobin build upx

os := $(shell uname | tr '[:upper:]' '[:lower:]')
arch := $(shell uname -m | sed 's/x86_64/amd64/')
version := $(shell git describe --tags --abbrev=0 2>/dev/null || (git rev-parse HEAD | cut -c-8))
sources := $(wildcard cmd/ytbx/*.go internal/cmd/*.go pkg/v1/ytbx/*.go)

all: test

clean:
go clean -i -r -cache
rm -rf internal/pycgo/updateYAML.c internal/pycgo/updateYAML.go internal/pycgo/__pycache__ binaries
rm -rf binaries

mrproper: clean
rm -rf third_party

gotest:
test:
ginkgo -r --nodes 1 --randomizeAllSpecs --randomizeSuites --race --trace

pythontest: third_party/lib/python
third_party/lib/python/bin/python3 internal/pycgo/updateYAML_test.py

test: gotest pythontest

third_party/lib/python:
@scripts/compilePythonLibrary.sh
gobin:
go build -ldflags='-s -w -extldflags "-static"' -o ${GOPATH}/bin/ytbx cmd/ytbx/main.go

internal/pycgo/updateYAML.c: third_party/lib/python internal/pycgo/updateYAML.py
$${HOME}/.local/bin/cython -3 --embed=updateYAML --output-file internal/pycgo/updateYAML.c internal/pycgo/updateYAML.py
build: binaries/ytbx-linux-amd64 binaries/ytbx-darwin-amd64 binaries/ytbx-windows-amd64

internal/pycgo/updateYAML.go: third_party/lib/python internal/pycgo/updateYAML.go.template
@scripts/createGoSourceFileFromTemplate.sh
binaries/ytbx-linux-amd64: $(sources)
GOOS=linux GOARCH=amd64 go build -ldflags='-s -w -extldflags "-static" -X github.com/HeavyWombat/ytbx/internal/cmd.version=$(version)' -o binaries/ytbx-linux-amd64 cmd/ytbx/main.go

build: third_party/lib/python internal/pycgo/updateYAML.c internal/pycgo/updateYAML.go
@mkdir -p binaries
go build -ldflags='-s -w' -o binaries/ytbx-$(os)-$(arch) cmd/ytbx/main.go
@echo
@ls -lh binaries/ytbx-$(os)-$(arch)
@echo
@bash -c 'if [[ "$(os)" == "linux" ]]; then readelf -d binaries/ytbx-$(os)-$(arch); fi'
@bash -c 'if [[ "$(os)" == "darwin" ]]; then otool -L binaries/ytbx-$(os)-$(arch); fi'
binaries/ytbx-darwin-amd64: $(sources)
GOOS=darwin GOARCH=amd64 go build -ldflags='-s -w -extldflags "-static" -X github.com/HeavyWombat/ytbx/internal/cmd.version=$(version)' -o binaries/ytbx-darwin-amd64 cmd/ytbx/main.go

upx: build
upx -q binaries/ytbx-$(os)-$(arch)
binaries/ytbx-windows-amd64: $(sources)
GOOS=windows GOARCH=amd64 go build -ldflags='-s -w -extldflags "-static" -X github.com/HeavyWombat/ytbx/internal/cmd.version=$(version)' -o binaries/ytbx-windows-amd64 cmd/ytbx/main.go
13 changes: 5 additions & 8 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,19 @@ import (
"fmt"
"os"

"github.com/HeavyWombat/ytbx/pkg/v1/ytbx"

"github.com/HeavyWombat/dyff/pkg/v1/neat"

"github.com/HeavyWombat/dyff/pkg/v1/dyff"
"github.com/spf13/cobra"

"github.com/HeavyWombat/dyff/pkg/v1/bunt"
"github.com/spf13/cobra"
"github.com/HeavyWombat/dyff/pkg/v1/dyff"
"github.com/HeavyWombat/dyff/pkg/v1/neat"
"github.com/HeavyWombat/ytbx/pkg/v1/ytbx"
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "ytbx",
Short: "YAML tool box",
Long: `YAML tool box provides a set of commands to inspect, display, or modify
the content of a given YAML or JSON file.`,
Long: `YAML tool box provides a set of commands to work with the content of a given YAML or JSON file.`,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
70 changes: 0 additions & 70 deletions internal/cmd/set.go

This file was deleted.

44 changes: 44 additions & 0 deletions internal/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright © 2018 Matthias Diester
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

var version string

// versionCmd represents the get command
var versionCmd = &cobra.Command{
Use: "version",
Args: cobra.ExactArgs(0),
Short: "Display version",
Long: "Displays the version of this tool",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("version %s\n", version)
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 820734e

Please sign in to comment.