File: new_id.lua

package info (click to toggle)
lua-systemd 0~git20160517-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 412 kB
  • sloc: ansic: 4,022; makefile: 3
file content (25 lines) | stat: -rwxr-xr-x 527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env lua
--[[
This program acts like `journalctl --new-id128`
]]

local id128 = require "systemd.id128"

local myuuid = tostring(assert(id128.randomise()))

io.write(table.concat({
	"As string:",
	myuuid,
	"",
	"As UUID:",
	myuuid:gsub("(........)(....)(....)(....)(........)", "%1-%2-%3-%4-%5"),
	"",
	"As macro:",
	"#define MESSAGE_XYZ SD_ID128_MAKE(" .. myuuid:gsub("(..)", "%1,"):sub(1,-2) .. ")",
	"",
	"As Python constant:",
	">>> import uuid",
	">>> MESSAGE_XYZ = uuid.UUID('" .. myuuid .. "')",
	""
},"\n"))