ros-template(1)

πŸ“¦ version 26.10.119, in alpine 3.24, arch rolling, nixos 26.05, nixpkgs unstable

okay bestie, welcome to ros-template(1) β€” the manual page for the template editor that pairs with ros-init. it's giving template-management main character energy, and ngl this page is lowkey a slay. πŸ’…βœ¨ we're gonna go through every flag and subcommand together, fr fr.

πŸ’– NAME πŸ’–

ros-template β€” Edit template for ros-init. πŸŽ€

🌸 SYNOPSIS 🌸

  • ros template command args...

✨ Subcommands ✨

  • init template-name β€” Create new template in local-project directory. πŸŽ€ fresh start energy
  • deinit template-name β€” Remove a template from local-project directory. bye-bye template πŸ‘‹
  • list β€” Show file list and states of the files type, chmod, rewrite in templates. receipts 🧾
  • checkout [template-name] β€” When invoked without template-name, this command shows candidates for current templates to operate. If with template-name, this command chooses the name as current template. current-template glow-up πŸ‘‘
  • add [template-name] [files ...] β€” Add files to current template. The first parameter could be taken as a template-name when the current template is default. file-wrangling 🫢
  • cat [template-name] [files ...] β€” Show contents in the current template. peek inside πŸ‘€
  • edit [template-name] [files ...] β€” Edit content of files in template using /usr/bin/editor. editor time ✍️
  • path [template-name] [files ...] β€” Show native path of files in template. where it lives πŸ—ΊοΈ
  • rm [template-name] [files ...] β€” Remove file from current template. delete πŸ’€
  • type [template-name] [type] [files ...] β€” Change file type. Current choices for types are djula or copy. {{name}} {{author}} {{email}} {{universal_time}} are available variables in the template file. Without files, change default type. strategy switch-up πŸ¦‹
  • chmod [template-name] [mode] [files ...] β€” Change file mode bits to generate. Specify mode in octal format. mode bits πŸ”
  • rewrite [template-name] file rewrite-rule β€” Change file name using djula template. Variables {{name}} {{author}} {{email}} {{universal_time}} are available for rewrite-rule. rename magic πŸͺ„
  • export [template-name] [directory] β€” Export files in current template to current directory. export πŸ“¦
  • import [directory] β€” Import template in current directory. import πŸ“₯
  • help β€” Show the subcommand help. help 🫢

πŸ¦‹ Description πŸ¦‹

The ros-template(1) command manages templates of projects. no cap. 🌈

πŸŽ€ Create template πŸŽ€

First, the init sub-command creates an empty template. ✨

$ ros template init sample-template

Many of the sub-commands take a template name as first argument. But you can omit it by the checkout sub-commands. After the following, such sub-commands are applied to sample-template. πŸ’–

$ ros template checkout sample-template

Next, the add sub-command adds local file[s] to template. Then, the list sub-command shows information of files in template. πŸŽ€

$ echo "Hello {{ author }}!!" > sample.txt
$ ros template add sample.txt
$ ros template list
      copy  sample.txt

The word copy means a strategy when applying the template. There are the following 2 strategies. πŸ‘‘

  • copy β€” simply copies the file as-is.
  • djula β€” processes the content of the file by template engine, Djula (http://mmontone.github.io/djula/).
    • Available variables are explained later.

The type sub-command changes it. In addition, default strategy (copy) can be changed for each template by the type sub-command without file names (Ex. ros template type djula). πŸ¦‹

$ ros template type djula sample.txt
$ ros template list
      djula sample.txt

The sample.txt will be simply output as sample.txt in default. But you can change it by the rewrite sub-command. In the following example, it will be output as sample_<project name>.txt. πŸ’«

$ ros template rewrite sample.txt "sample-{{ name }}.txt"
$ ros template list
      djula sample.txt -> "sample-{{ name }}.txt"
Note: Rewrite rules are always processed by Djula irrespective of strategy of the file. ⚠️

πŸŽ€ Apply template πŸŽ€

ros-init(1) can specify a template. 🌸

$ mkdir temp ; cd temp
$ ros init sample-template some-project
$ ls
sample-some-project.txt
$ cat sample-some-project.txt # Assume that "author" is "alien"
Hello alien!!

The file name and its content are processed by Djula as explained in the above. The following variables can be used in default. πŸ‘‘

  • {{name}}: A project name specified in ros-init(1)
  • {{author}}: An author name extracted from config of Git or whoami
  • {{email}}: An e-mail address extracted from config of Git or created using whoami and hostname
  • {{universal_time}}: A universal time created by get-universal-time function

In addition, you can use original variables as the followings. πŸ’…

$ echo "Hello {{ area }}!!" > sample.txt
$ ros template add sample.txt # Note: It overwrites existing
$ mkdir temp ; cd temp
$ ros init sample-template roswell --area 51
$ cat sample-roswell.txt
Hello 51!!

πŸŽ€ Export and import template πŸŽ€

Basically, ros-template(1) is designed to internally manage added files. 🧚

However, if you want to, for example, manage it using Git in a local directory or to install distributed templates, you can use the export and import sub-commands. πŸŽ€

First, the export sub-command exports added files and a setting file roswell.init.<template name>.asd that is internally created and edited. ✨

$ ros template export dir
$ ls dir
roswell.init.sample-template.asd  sample.txt
$ cat dir/sample.txt
Hello {{ area }}!!

Second, the import sub-command imports them. 🫢

# Assume that this is another machine...
$ ros template list sample-template # nothing is output
$ ls downloaded
roswell.init.sample-template.asd  sample.txt
$ ros template import downloaded
$ ros template list sample-template
      djula sample.txt -> "sample-{{ name }}.txt"
Note: If there is a template whose name is same, it will be overwritten. πŸ’€

πŸ‘€ SEE ALSO πŸ‘€

ros(1) ros-init(1)

πŸ‘‘ AUTHORS πŸ‘‘

Roswell Project Team.

okay that's the whole page, bestie β€” the footer has no source/version/date line to report, just the ros-template(1) manual name again. go make something iconic! πŸ’–βœ¨

πŸ“¦ where this page comes from