Skip to content

Commit

Permalink
Adjust output script style, use printstyled (JuliaPackaging#146)
Browse files Browse the repository at this point in the history
* Fix a couple of stylistic oddities

* Use printstyled instead of print_with_color
  • Loading branch information
ararslan authored and staticfloat committed Feb 15, 2018
1 parent e04ad86 commit 35f4e9f
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
julia 0.6
BinaryProvider
ObjectFile
Compat 0.27.0
Compat 0.50.0
Reexport
TerminalMenus
MbedTLS
Expand Down
2 changes: 1 addition & 1 deletion src/RootFS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function download_osx_sdk(;automatic::Bool = automatic_apple,
legal terms you agree to when using the SDK to build software for Apple
operating systems: https://images.apple.com/legal/sla/docs/xcode.pdf.
""")
print_with_color(:bold, msg)
printstyled(msg, bold=true)
println()
while true
print("Would you like to download and use the macOS SDK? [y/N]: ")
Expand Down
2 changes: 1 addition & 1 deletion src/Wizard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function run_wizard(state::WizardState = WizardState())
catch err
if isa(err, InterruptException)
msg = "\n\nWizard stopped, use run_wizard(ans) to resume.\n\n"
print_with_color(:red, state.outs, msg, bold=true)
printstyled(state.outs, msg, bold=true, color=:red)
else
bt = catch_backtrace()
Base.showerror(STDERR, err, bt)
Expand Down
16 changes: 8 additions & 8 deletions src/wizard/deploy.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function print_build_tarballs(io::IO, state::WizardState;
with_travis_tags=false)
platforms_string = string("[\n ",join(state.platforms,",\n "),"\n]\n")
platforms_string = string("[\n ",join(state.platforms,",\n "),"\n]\n")
urlhashes = zip(state.source_urls, state.source_hashes)
sources_string = string("[\n",join(map(urlhashes) do x
(src, hash) = x
Expand Down Expand Up @@ -55,7 +55,7 @@ function print_build_tarballs(io::IO, state::WizardState;
$(state.history)
\"\"\"
products = prefix -> [
products(prefix) = [
$products_string
]
Expand Down Expand Up @@ -194,7 +194,7 @@ end

function obtain_token(outs, ins, repo_name, user)
println(outs)
print_with_color(:bold, "Creating a github access token.\n")
printstyled("Creating a github access token.\n", bold=true)
println(outs, """
We will use this token to create to repository, and then pass it to travis
for future uploads of binary artifacts.
Expand Down Expand Up @@ -232,7 +232,7 @@ function obtain_token(outs, ins, repo_name, user)
status_exception=false, basic_authorization=true)
end
if resp.status == 401
print_with_color(:red, outs, "Invalid credentials!\n")
printstyled(outs, "Invalid credentials!\n", color=:red)
continue
end
if resp.status != 200
Expand All @@ -251,7 +251,7 @@ function common_git_repo_setup(repo_dir, repo, state)
license_text = try
PkgDev.readlicense(lic)
catch
print_with_color(:red, "License $lic is not available.")
printstyled("License $lic is not available.", color=:red)
println("Available licenses are:")
foreach(PkgDev.LICENSES) do lic
println("- $(lic[1])")
Expand Down Expand Up @@ -434,12 +434,12 @@ end


function step7(state::WizardState)
print_with_color(:bold, state.outs, "\t\t\tDone!\n\n")
printstyled(state.outs, "\t\t\tDone!\n\n", bold=true)

print(state.outs, "Your build script was:\n\n\t")
print(state.outs, replace(state.history, "\n", "\n\t"))

print_with_color(:bold, state.outs, "\t\t\t# Step 7: Deployment\n\n")
printstyled(state.outs, "\t\t\t# Step 7: Deployment\n\n", bold=true)

while true
msg = strip("""
Expand All @@ -449,7 +449,7 @@ function step7(state::WizardState)
state.name = readline(state.ins)
println(state.outs)
if isempty(state.name)
print_with_color(:red, state.outs, "Name may not be empty!\n")
printstyled(state.outs, "Name may not be empty!\n", color=:red)
continue
end
break
Expand Down
6 changes: 3 additions & 3 deletions src/wizard/hints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Print a hint for projets that use autoconf to have a good `./configure` line.
function print_autoconf_hint(state::WizardState)
print(state.outs, " The recommended options for GNU Autoconf are")
print(state.outs, " `")
print_with_color(:bold, state.outs, "./configure --prefix=\$prefix --host=\$target")
printstyled(state.outs, "./configure --prefix=\$prefix --host=\$target", bold=true)
println(state.outs, "`")
println(state.outs, " followed by `make` and `make install`. Since the prefix environment")
println(state.outs, " variable is set already, this will automatically perform the installation")
Expand All @@ -26,7 +26,7 @@ function provide_hints(state::WizardState, path::AbstractString)
println(state.outs, join(map(x->string(" - ", x),files),'\n'))
printed = false
function start_hints()
printed || print_with_color(:yellow, state.outs, "Hints:\n")
printed || printstyled(state.outs, "Hints:\n", color=:yellow)
printed = true
end
# Avoid providing duplicate hints (even for files in separate directories)
Expand Down Expand Up @@ -58,7 +58,7 @@ function provide_hints(state::WizardState, path::AbstractString)
print(state.outs, " This file is likely input to CMake. ")
print(state.outs, "The recommended options for CMake are\n")
print(state.outs, " `")
print_with_color(:bold, state.outs, "cmake -DCMAKE_INSTALL_PREFIX=\$prefix -DCMAKE_TOOLCHAIN_FILE=/opt/\$target/\$target.toolchain")
printstyled(state.outs, "cmake -DCMAKE_INSTALL_PREFIX=\$prefix -DCMAKE_TOOLCHAIN_FILE=/opt/\$target/\$target.toolchain", bold=true)
println(state.outs, "`")
println(state.outs, " followed by `make` and `make install`. Since the prefix environment")
println(state.outs, " variable is set already, this will automatically perform the installation")
Expand Down
28 changes: 14 additions & 14 deletions src/wizard/interactive_build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The fourth step selects build products after the first build is done
"""
function step4(state::WizardState, ur::Runner, platform::Platform,
build_path::AbstractString, prefix::Prefix)
print_with_color(:bold, state.outs, "\t\t\t# Step 4: Select build products\n\n")
printstyled(state.outs, "\t\t\t# Step 4: Select build products\n\n", bold=true)

# Collect all executable/library files
files = collapse_symlinks(collect_files(prefix; exculuded_files=state.dependency_files))
Expand All @@ -35,7 +35,7 @@ function step4(state::WizardState, ur::Runner, platform::Platform,
terminal = TTYTerminal("xterm", state.ins, state.outs, state.outs)

if length(files) == 0
print_with_color(:red, state.outs, "ERROR: ")
printstyled(state.outs, "ERROR: ", color=:red)
println(state.outs, "The build has produced no binary artifacts.")
println(state.outs, " "^7, "This is generally because an error occured during the build")
println(state.outs, " "^7, "or because you forgot to `make install` or equivalent.")
Expand Down Expand Up @@ -87,7 +87,7 @@ end
Audit the `prefix`.
"""
function step3_audit(state::WizardState, platform::Platform, prefix::Prefix)
print_with_color(:bold, state.outs, "\n\t\t\tAnalyzing...\n\n")
printstyled(state.outs, "\n\t\t\tAnalyzing...\n\n", bold=true)

audit(prefix; io=state.outs,
platform=platform, verbose=true, autofix=true)
Expand Down Expand Up @@ -121,7 +121,7 @@ function interactive_build(state::WizardState, prefix::Prefix,
rm(histfile)
end

print_with_color(:bold, state.outs, "\n\t\t\tBuild complete\n\n")
printstyled(state.outs, "\n\t\t\tBuild complete\n\n", bold=true)
print(state.outs, "Your build script was:\n\n\t")
print(state.outs, replace(state.history, "\n", "\n\t"))
println(state.outs)
Expand Down Expand Up @@ -173,7 +173,7 @@ function step3_retry(state::WizardState)
platform = pick_preferred_platform(state.platforms)

msg = "\t\t\t# Attempting to build for $platform\n\n"
print_with_color(:bold, state.ins, msg)
printstyled(state.ins, msg, bold=true)

build_path = tempname()
mkpath(build_path)
Expand Down Expand Up @@ -245,7 +245,7 @@ function step34(state::WizardState)
platform = pick_preferred_platform(state.platforms)
push!(state.visited_platforms, platform)

print_with_color(:bold, state.outs, "\t\t\t# Step 3: Build for $(platform)\n\n")
printstyled(state.outs, "\t\t\t# Step 3: Build for $(platform)\n\n", bold=true)

msg = strip("""
You will now be dropped into the cross-compilation environment.
Expand Down Expand Up @@ -283,7 +283,7 @@ end

function step5_internal(state::WizardState, platform::Platform, message)
print(state.outs, "Your next build target will be ")
print_with_color(:bold, state.outs, platform)
printstyled(state.outs, platform, bold=true)
println(state.outs, message)
println(state.outs)
println(state.outs, "Press any key to continue...")
Expand All @@ -292,7 +292,7 @@ function step5_internal(state::WizardState, platform::Platform, message)

terminal = TTYTerminal("xterm", state.ins, state.outs, state.outs)

print_with_color(:bold, state.ins, "\t\t\t# Attempting to build for $platform\n\n")
printstyled(state.ins, "\t\t\t# Attempting to build for $platform\n\n", bold=true)

build_path = tempname()
mkpath(build_path)
Expand All @@ -319,15 +319,15 @@ function step5_internal(state::WizardState, platform::Platform, message)

while true
msg = "\n\t\t\tBuild complete. Analyzing...\n\n"
print_with_color(:bold, state.outs, msg)
printstyled(state.outs, msg, bold=true)

audit(prefix; io=state.outs,
platform=platform, verbose=true, autofix=true)

ok = isempty(match_files(state, prefix, platform, state.files))
if !ok
println(state.outs)
print_with_color(:red, state.outs, "ERROR: ")
printstyled(state.outs, "ERROR: ", color=:red)
msg = "Some build products could not be found (see above)."
println(state.outs, msg)
println(state.outs)
Expand Down Expand Up @@ -415,7 +415,7 @@ function step5_internal(state::WizardState, platform::Platform, message)
end

function step5a(state::WizardState)
print_with_color(:bold, state.outs, "\t\t\t# Step 5: Generalize the build script\n\n")
printstyled(state.outs, "\t\t\t# Step 5: Generalize the build script\n\n", bold=true)

# We will try to pick a platform for a different operating system
possible_platforms = filter(state.platforms) do plat
Expand Down Expand Up @@ -522,10 +522,10 @@ function step5c(state::WizardState)
end
print(state.outs, "[")
if ok
print_with_color(:green, state.outs, "")
printstyled(state.outs, "", color=:green)
push!(state.validated_platforms, platform)
else
print_with_color(:red, state.outs, "")
printstyled(state.outs, "", color=:red)
push!(state.failed_platforms, platform)
end
println(state.outs, "]")
Expand All @@ -549,7 +549,7 @@ function step6(state::WizardState)
terminal = TTYTerminal("xterm", state.ins, state.outs, state.outs)

msg = "\t\t\t# Step 6: Revisit failed platforms\n\n"
print_with_color(:bold, state.outs, msg)
printstyled(state.outs, msg, bold=true)

println(state.outs, "Several platforms failed to build:")
for plat in state.failed_platforms
Expand Down
12 changes: 6 additions & 6 deletions src/wizard/obtain_source.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function download_source(state::WizardState)
url = canonicalize_source_url(entered_url)
if url != entered_url
print(state.outs, "The entered URL has been canonicalized to\n")
print_with_color(:bold, state.outs, url)
printstyled(state.outs, url, bold=true)
println(state.outs)
println(state.outs)
end
Expand Down Expand Up @@ -108,7 +108,7 @@ function download_source(state::WizardState)

# Tell the user what we recorded the current commit as
print(state.outs, "Recorded as ")
print_with_color(:bold, state.outs, source_hash)
printstyled(state.outs, source_hash, bold=true)
println(state.outs)
close(repo)
else
Expand Down Expand Up @@ -156,7 +156,7 @@ This step selets the relevant platform(s) for the built binaries.
function step1(state::WizardState)
# Select a platform
msg = "\t\t\t# Step 1: Select your platforms\n\n"
print_with_color(:bold, state.outs, msg)
printstyled(state.outs, msg, bold=true)
terminal = TTYTerminal("xterm", state.ins, state.outs, state.outs)
platform_select = request(terminal,
"Make a platform selection",
Expand Down Expand Up @@ -219,7 +219,7 @@ end

function obtain_binary_deps(state::WizardState)
msg = "\t\t\t# Step 2b: Obtain binary dependencies (if any)\n\n"
print_with_color(:bold, state.outs, msg)
printstyled(state.outs, msg, bold=true)

q = "Do you require any (binary) dependencies? "
if yn_prompt(state, q, :n) == :y
Expand All @@ -244,7 +244,7 @@ function obtain_binary_deps(state::WizardState)
canon_url = canonicalize_url(url)
if url != canon_url
print(state.outs, "The entered URL has been canonicalized to\n")
print_with_color(:bold, state.outs, canon_url)
printstyled(state.outs, canon_url, bold=true)
println(state.outs)
println(state.outs)
end
Expand All @@ -270,7 +270,7 @@ end

function obtain_source(state::WizardState)
msg = "\t\t\t# Step 2a: Obtain the source code\n\n"
print_with_color(:bold, state.outs, msg)
printstyled(state.outs, msg, bold=true)

# Create the workspace that we'll stash everything within
state.workspace = tempname()
Expand Down
2 changes: 1 addition & 1 deletion test/build_libfoo_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if length(ARGS) > 0
end
info("Building for $(join(triplet.(build_platforms), ", "))")

products = prefix -> [
products(prefix) = [
LibraryProduct(prefix, "libfoo"),
ExecutableProduct(prefix, "fooifier")
]
Expand Down

0 comments on commit 35f4e9f

Please sign in to comment.