# Announcing Term.jl

**URL:** https://discourse.julialang.org/t/announcing-term-jl/78170
**Category:** Package Announcements
**Tags:** package, announcement, cli
**Created:** [March 20, 2022, 6:01pm UTC](https://discourse.julialang.org/t/announcing-term-jl/78170 "2022-03-20T18:01:23Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [August 27, 2022, 4:40am UTC](https://discourse.julialang.org/t/announcing-term-jl/78170/21 "2022-08-27T04:40:28Z")

</div>

Thanks for the quick answer, it helps!

Albeit a bit too nitty gritty for me, will make a post and see if others have found a good solution 🙂

Kind regards

---

<div class="post-metadata">

### Author: ![Jollywatt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jollywatt/32/202198_2.png) [@Jollywatt](https://discourse.julialang.org/u/Jollywatt)
#### Post date: [August 27, 2022, 9:12am UTC](https://discourse.julialang.org/t/announcing-term-jl/78170/22 "2022-08-27T09:12:22Z")

</div>

This package looks great!

One comment I have is that macros are used unnecessarily. The string style functions like `@red`, `@bold` or `@underline` don’t do anything that a function couldn’t do, and should really just be exposed to the user as normal functions.

I.e., define

```julia
function red(txt)
    code = ANSICode(get_color("red"); bg = false)
    styled = apply_style(txt)
    code.open * styled * code.close
end

```

instead of

```julia
macro red(text)
    quote
        local txt = $(esc(text))
        code = ANSICode(get_color("red"); bg = false)
        styled = apply_style(txt)
        string(code.open * styled * code.close)
    end
end

```

as in [`macros.jl`](https://github.com/FedeClaudi/Term.jl/blob/master/src/macros.jl).

I agree that a little syntactic sugar would be nice, though. I propose something like

```julia
julia> macro red_str(txt)
           code = ANSICode(get_color("red"); bg = false)
           code.open*apply_style(string(txt))*code.close
       end
@red_str (macro with 1 method)

julia> red"apple"
"\e[31mapple\e[39m"

```

Another neat available (but less readable) syntax might be:

```julia
julia> const style_flags = Dict('r' => "red", 'u' => "underline");

julia> macro c_str(txt, flags)
               styles = [getindex(style_flags, flag) for flag in flags]
               println("applying styles: ", styles)
               txt
       end
@c_str (macro with 1 method)

julia> c"hello"ru
applying styles: ["red", "underline"]
"hello"

```

---

<div class="post-metadata">

### Author: ![FedeClaudi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedeclaudi/32/33490_2.png) [@FedeClaudi](https://discourse.julialang.org/u/FedeClaudi)
#### Post date: [August 27, 2022, 1:25pm UTC](https://discourse.julialang.org/t/announcing-term-jl/78170/23 "2022-08-27T13:25:12Z")

</div>

hey thanks!

That’s a fair point.  
However I don’t see much of a change between using `@red` and `@red_str` and making this change would break existing code for users that have been using the macros as they are. Given that it would be just a small syntactic change I don’t think it makes it worth it to have this breaking change.

Thanks for the input though, get in touch if you have more ideas/requests!

---

<div class="post-metadata">

### Author: ![FedeClaudi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedeclaudi/32/33490_2.png) [@FedeClaudi](https://discourse.julialang.org/u/FedeClaudi)
#### Post date: [August 27, 2022, 1:25pm UTC](https://discourse.julialang.org/t/announcing-term-jl/78170/24 "2022-08-27T13:25:24Z")

</div>

Keep me posted!

[Previous page](https://discourse.julialang.org/t/announcing-term-jl/78170.md?page=1)
