Skip to content

Commit

Permalink
Refactor and enhance Colorize
Browse files Browse the repository at this point in the history
- Refactor all codes.
  * Prefer to use enums instead of constants.
  * Separate `Object` and `Style`. `Style` represents a style on
  terminal purely, however `Object` has object content.
- Support 256 color and 32bit true color.
- Support TTY detection. Three policy:
  * `Auto`: If given io is TTY, then output colorized text.
  * `Always`: Output colorized text always.
  * `Never`: Not output colorized text.
- Add command line option for `--color` to specify colorize policy.
  * Add `color` option to Makefile.
- Comment for document more.
- Rewrite tests for this changes.
- More and more...
  • Loading branch information
makenowjust committed Jan 23, 2017
1 parent ccf46c0 commit 0418bfb
Show file tree
Hide file tree
Showing 24 changed files with 1,112 additions and 466 deletions.
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@

LLVM_CONFIG ?= ## llvm-config command path to use

release ?= ## Compile in release mode
stats ?= ## Enable statistics output
threads ?= ## Maximum number of threads to use
debug ?= ## Add symbolic debug info
verbose ?= ## Run specs in verbose mode
release ?= ## Compile in release mode
stats ?= ## Enable statistics output
threads ?= ## Maximum number of threads to use
debug ?= ## Add symbolic debug info
verbose ?= ## Run specs in verbose mode
color ?= auto ## Colorize the output

O := .build
SOURCES := $(shell find src -name '*.cr')
SPEC_SOURCES := $(shell find spec -name '*.cr')
FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(threads),--threads $(threads) )$(if $(debug),-d )
FLAGS := --color=$(color)$(if $(release), --release)$(if $(stats), --stats)$(if $(threads), --threads $(threads))$(if $(debug), -d)
VERBOSE := $(if $(verbose),-v )
COLOR := --color=$(color)
EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=`pwd`/src)
SHELL = bash
LLVM_CONFIG_FINDER := \
Expand Down Expand Up @@ -73,15 +75,15 @@ help: ## Show this help

.PHONY: spec
spec: $(O)/all_spec ## Run all specs
$(O)/all_spec $(VERBOSE)
$(O)/all_spec $(COLOR) $(VERBOSE)

.PHONY: std_spec
std_spec: $(O)/std_spec ## Run standard library specs
$(O)/std_spec $(VERBOSE)
$(O)/std_spec $(COLOR) $(VERBOSE)

.PHONY: compiler_spec
compiler_spec: $(O)/compiler_spec ## Run compiler specs
$(O)/compiler_spec $(VERBOSE)
$(O)/compiler_spec $(COLOR) $(VERBOSE)

.PHONY: doc
doc: ## Generate standard library documentation
Expand Down
8 changes: 4 additions & 4 deletions bin/ci
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ prepare_system() {
}

build() {
with_build_env 'make std_spec clean'
with_build_env 'make crystal spec doc'
with_build_env 'find samples -name "*.cr" | xargs -L 1 ./bin/crystal build --no-codegen'
with_build_env './bin/crystal tool format --check samples spec src'
with_build_env 'make std_spec clean color=always'
with_build_env 'make crystal spec doc color=always'
with_build_env 'find samples -name "*.cr" | xargs -L 1 ./bin/crystal build --color=always --no-codegen'
with_build_env './bin/crystal tool format --color=always --check samples spec src'
}

deploy() {
Expand Down
Loading

0 comments on commit 0418bfb

Please sign in to comment.