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

[repo] V2.53 - Add wrayth links to repo output #1282

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

emcguinness
Copy link
Contributor

Initial draft to show a possible implementation. Before this change a ;repo download action pauses for 3 seconds before continuing, due to ease of accidentally clicking a link logic is added to prompt for user confirmation via ;send and if not given in time the script will exit without downloading.

This is achieved by adding a '--clicked' link to all links the script generates, this means any manual ;repo download commands will still exhibit old behaviour. This means new feature (links) new behaviour (;send confirmation instead of auto download after timeout). This behavior could become the default for all "dangerous" actions.

In this current from the new behavior is only implemented into download action but will be added to delete and (probably) rate as that will cover the three "dangerous" actions that could be done via the links.

First download command example of no duplicate names, second download is with duplicates (bonus text appears to explain how to download).
First appearance of ">alias.lic" is a link click, this one no response is given and times out
Second appearance of ">alias.lic" is a link click, followed by a confirmation (and download completing)
image

scripts/repository.lic Outdated Show resolved Hide resolved
@emcguinness
Copy link
Contributor Author

emcguinness commented Sep 13, 2023

Moved confirmation logic to proc for re-use and added to rate and delete (in addition to the download) which I think covers all the "dangerous" actions that could be performed via link clicks. Getting pretty close now but need to run though all commands to check for accidental side effects.

image

@emcguinness
Copy link
Contributor Author

Tested commands that call format_list and are affected by this change:

  1. List - click for info
  2. list-updates - click for info
    • Could be a case to be argued for click to download given context but info feels better to me (check info before downloading update)
  3. list-new - click for info
  4. info - If multiple match produces list with click for info
    • TODO: add text prompt with help for cli flags for non clicky clients
  5. download - If multiple match produces list with click for download, prompts for confirmation first
  6. set-updatable - (Just added) If multiple match produces list with click to set updatable, prompts for confirmation first
    • TODO: add text prompt with help for cli flags for non clicky clients
  7. delete - If multiple match produces list with click to delete, prompts for confirmation first
    • TODO: add text prompt with help for cli flags for non clicky clients
  8. rate - If multiple match produces list with click to rate, prompts for confirmation first
    • TODO: add text prompt with help for cli flags for non clicky clients

Other things of note:

  1. show-updatable - As the table is done differently not affected by this change, quick POC shows it could work but throws column size off if done before table creation. Might revisit this.
  2. unset-updatable - Posible slight bug (unrelated to these changes), if two or more scripts partially match the name you are trying to unset it will just remove one at a time without prompt.

;repo unset-updatable flet
--- Lich: repository active.
[repository: the download-updates command will ignore updates for fletchmaster.lic]
--- Lich: repository has exited.
;repo unset-updatable flet
--- Lich: repository active.
[repository: the download-updates command will ignore updates for fletching.lic]

@emcguinness
Copy link
Contributor Author

Moved the "duplicate file" help text to a proc and called anywhere it is required. Moving out of draft now as think this is about there.

Final maybe todo to check on is adding links to show-updatable for completeness.

@emcguinness emcguinness marked this pull request as ready for review September 13, 2023 17:40
@emcguinness
Copy link
Contributor Author

Looking like a no on the show-updatable for this release. If you add the XML before creating the table it will set the column widths all wrong. There is currently no way to set the width of a single column, all columns have to be same size. There is a issue raised to fix this, maybe return once that is done.

tj/terminal-table#64

@mrhoribu
Copy link
Contributor

mrhoribu commented Sep 14, 2023

Looking like a no on the show-updatable for this release. If you add the XML before creating the table it will set the column widths all wrong. There is currently no way to set the width of a single column, all columns have to be same size. There is a issue raised to fix this, maybe return once that is done.

tj/terminal-table#64

Yep, you have to add the XML code AFTER the fact, otherwise the table spacing adjusts for the extra xml even though it's not shown on the client. You can see what I did here for resource.lic to allow for monsterbolding the header text

    table = table.to_s
    if table =~ /\n\|([\w\d\s\|\$\/\(\)\.]+)\|\n/
      header = $1
      headerbold = Lich::Messaging.monsterbold(header)
      table = table.gsub(header, headerbold)
    end
    _respond "<output class=\"mono\"/>\n" + table + "\n<output class=\"\"/>"
  end

Could probably use this regex match:

\n\| ([\w\d-]+\.(?:xml|lic|rb|json|yaml|yml))\s+\| [\w\d\-]+\s+\| (?:gs|dr|any)\s+\|\n

To then gsub in the appropriate clicky needed

@emcguinness
Copy link
Contributor Author

Ok all commands I could think of tested and the last push fixes things for when using the --hide-author flag.

If there is no author but there is a name clash you will get the game field, this gets added to the link. If there is no author and no name clash then we have nothing but the name left, this will still get turned into a link. I think in this final case there is likely a chance of a clash but as the clicky links do not have the --hide-author flag the problem will correct itself with worse case scenario of one extra click.

This point I think I am done with anything I can think of, so just any final comments/suggestions.

Fixed issue with using rjust due to new <d cmd> stuff in links causing it to get confused and not allowing it to justify filennames properly.
Created a output_mono_msg proc to send mono txt
missed one update for a mono call.
@mrhoribu
Copy link
Contributor

This should be good now for full testing. Updated output listings to be in mono format.

@Deysh Deysh requested a review from mrhoribu November 19, 2023 10:59
@mrhoribu mrhoribu changed the title [repo] V2.49 - Add wrayth links to repo output [repo] V2.53 - Add wrayth links to repo output May 12, 2024
add `--search` option to help output
@mrhoribu mrhoribu marked this pull request as draft May 15, 2024 20:21
@mrhoribu
Copy link
Contributor

Tried running once again to see if usable and ran into some Ruby errors that need to be resolved first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants