#命令行工具 #字符串 # #字体 #背景 #偏移 #

app bigstr

一个将字符串变为大写的命令行工具

2个版本

0.1.1 2024年6月25日
0.1.0 2024年6月25日

394文本处理

MIT 许可证

24KB
379 代码行

BigStr

一个将字符串变为大写的命令行工具

示例

$ echo "BIGSTR" | bigstr -f 'DejaVuSansM Nerd Font' -s 17 --background '=' --offset -0.2
========================================================================================
========================================================================================
========================================================================================
==╭──────────╮===╭──────────╮====╭────────╮===╭─────────╮╭────────────────────────╮=====
==│  ╭─────╮ ╰╮==╰───╮  ╭───╯==╭─╯╭───────╯=╭─╯╭────────╯╰─────╮  ╭─────╮  ╭─────╮╰─╮===
==│  =====╰╮ ======│  =====╭╯ ╭╯=========│  ===============│  =====│  =====│  ===
==│  =====╭╯ ======│  =====│ ╭╯==========│  ╰╮==============│  =====│  =====│  ===
==│  ╰─────╯ ╭╯======│  │====╭╯ │===========╰─╮ ╰─────╮========│  │=====│  ╰─────╯ ╭╯===
==│  ╭─────╮ ╰╮======│  │====│  │====╭─────╮==╰─────╮ ╰─╮======│  │=====│         ╭╯====
==│  =====╰╮ ╰╮=====│  ====╰╮ ╰╮===╰──╮  ========╰─╮ ╰╮=====│  =====│  ╭────╮ ╰╮====
==│  ======│  =====│  =====│  ======│  ==========│  =====│  =====│  ====╰─╮╰╮===
==│  ====╭─╯ ╭╯=====│  =====╰╮ ╰─╮====│  │╭──╮=====╭╯ ╭╯=====│  =====│  ======│ ╰╮==
==│  ╰────╯ ╭─╯==╭───╯  ╰───╮==╰──╮╰────╯╭─╯╰╮ ╰─────╯╭─╯======│ ╭╯=====│ ╭╯======╰╮ ╰╮=
==╰─────────╯====╰──────────╯=====╰──────╯===╰────────╯========╰─╯======╰─╯========╰──╯=
========================================================================================
========================================================================================
========================================================================================


$ bigstr -f Arial -s 12 -m BigsTR
                                                                     
                                                                     
 ╭────────╮    ╭─╮                       ╭─────────╮   ╭─────────╮   
  ╭─────╮╰╮   ╰─╯                       ╰───╮ ╭───╯   │╭───────╮╰╮  
  │     │ │   ╭─╮   ╭─╮ ╭───╮ ╭──╮╭──╮      │ │       ││      ╭╯╭╯  
  ╰─────╯ │   │ │  ╭╯╭╯ ╰─╮ │ │ ╭╯╰──╯      │ │       │╰──────╱─╯   
  ╭──────╮╰╮  │ │  │╭╯    │ │ ╰─╲────╮      │ │       │╭────╮ ╰╮    
  │      │ │  │ │  │╰╮   ╭╯ │ ╭─╱───╮╰╮     │ │       ││    ╰─╮╰╮   
  ╰──────╱─╯  │ │  ╰─╲───╯  │ ╰╮╰───╯╭╯     │ │       ││      ╰╮╰╮  
 ╰────────╯    ╰─╯  ╭─╱───╮ ╭╯  ╰─────╯      ╰─╯       ╰╯       ╰─╯  
                    ╰╮╰───╯╭╯                                        
                     ╰─────╯                                         

用法

$ bigstr --help
A command-line tool to make string BIG

Usage: bigstr [OPTIONS] [COMMAND]

Commands:
  list  show list of available fonts
  help  Print this message or the help of the given subcommand(s)

Options:
  -f, --famliy <FAMLIY>
          A name of font famliy

      --font-file <FONT_FILE>
          A path to a font file

  -m, --message <MESSAGE>
          A message to render, if not specified, read from stdin

  -s, --size <SIZE>
          The height of the rendered text
          
          [default: 18]

  -o, --offset <OFFSET>
          Each character will be offseted by this value
          
          i.e. -1.0 means the character will be moved 100% of its width to the left,
          
          0.0 means no offset,
          
          1.0 means the character will be moved 100% of its width to the right.
          
          Giving values like -0.5 will make the characters overlap a little. Have Fun!
          
          [default: 0.0]

  -t, --threshold <THRESHOLD>
          The threshold to determine whether a pixel is foreground or background
          
          [default: 0.5]

  -b, --background <BACKGROUND>
          The background character
          
          [default: " "]

      --mode <MODE>
          The mode to render the text
          
          "round": the rendered text will be rounded
          
          "square": the rendered text will be squared
          
          default is "round"
          
          [default: round]

  -a, --aspect-ratio <ASPECT_RATIO>
          The aspect ratio of the cursor
          
          The ratio height/width of actual rendered character (e.g. the unicode box drawing characters)
          
          Since we use (mono) character as pixel, the proper aspect ratio should be given to make the image looks good
          
          [default: 2.0]


  -w, --width <WIDTH>
          The maximum width of the rendered image
          
          If a single character cannot be fit into this width, the program will panic
          
          If the given string exceeds this width, it will be wrapped into multiple lines
          
          [default: 80]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

依赖项

~2.2–4.5MB
~85K SLoC