Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for variables in text for dynamic content #362

Closed
bartreardon opened this issue Apr 10, 2024 · 2 comments
Closed

Add support for variables in text for dynamic content #362

bartreardon opened this issue Apr 10, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request in progress

Comments

@bartreardon
Copy link
Collaborator

Not directly related but inspired by SecondSonConsulting/Baseline#46 @BigMacAdmin

Add variable support that generates a list of facts about a device that is able to be used wherever text can be used.

For example, common variables might be:

  • computername
  • computermodel
  • serialnumber
  • username
  • osversion
  • osname
  • osrevision
    ...etc

It could also be possible to use any named environment variable, including any custom ones.

Example usage

You could specify a line of text or .md file with variables you wish to populate:

You are running macOS {osname} on revision {osrevision} and your hardware is a {computermodel}

This would result in the following (example):

You are running macOS Sonoma on revision 14.4.1 and your hardware is a MacBookPro18,3

Custom variables could be supported provided they were exported prior to execution. unpopulated variables would result in blank output

export custominformation="<custom content here>"

which could then be used

Custom information contents is {custominformation}

Use case?

Rather than generating this info on the fly and customising content to be displayed prior to running swiftDialog, you could use boilerplate text that calls on this information and populates it for you.

If everything is contained in a shell script this might be less useful but given the capability of using a markdown file sourced from a URL, it could be desirable to populate the markdown file with variable names that swiftDialog will replace on the fly and reducing the need to include any pre-processing of text to populate dynamic content.

@bartreardon bartreardon self-assigned this Apr 10, 2024
@bartreardon bartreardon added the enhancement New feature or request label Apr 10, 2024
@BigMacAdmin
Copy link
Collaborator

Also useful: {Full Name} id -F

bartreardon added a commit that referenced this issue Apr 18, 2024
need to integrate `processEmbeddedVariables` into the general json procesing routine so it's available for all areas where text is available.
bartreardon added a commit that referenced this issue Apr 18, 2024
…sname}` can be present in any location where strings are used

Also, any environemtn variable can be accessed in a string with {VARNAME} - so `export MY_VAR="Some Value"` can be accessed in a string as `--message "MY_VAR is {MY_VAR}` - Useful? you could just as easily use `${MY_VAR}` but this is a added benefit to the built in system variable support.

Moved the `<br>` and `<hr>` detection to the string processing function
Fixed an issue with Infobox where short text was not topleft justified.
@bartreardon
Copy link
Collaborator Author

implemented in v2.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in progress
Projects
None yet
Development

No branches or pull requests

2 participants