Copy whole object
This commit is contained in:
parent
a88e8fe7d6
commit
1900bf0f72
2 changed files with 26 additions and 12 deletions
|
|
@ -373,16 +373,23 @@ PROJECT-NAME is the display name for the project."
|
|||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map tabulated-list-mode-map)
|
||||
(define-key map "q" #'ppq-quit)
|
||||
(define-key map "w" #'ppq-models-copy-id)
|
||||
(define-key map "w" #'ppq-models-copy-nix-entry)
|
||||
map))
|
||||
|
||||
(defun ppq-models-copy-id ()
|
||||
"Copy the ID of the current model to clipboard."
|
||||
(defun ppq-models-copy-nix-entry ()
|
||||
"Copy the current model as a Nix attribute set to clipboard."
|
||||
(interactive)
|
||||
(when tabulated-list-entries
|
||||
(let* ((entry (tabulated-list-get-entry))
|
||||
(id (aref entry 1)))
|
||||
(kill-new id)
|
||||
(let* ((id (tabulated-list-get-id))
|
||||
(model (seq-find (lambda (m) (equal (ppq--aget m 'id) id))
|
||||
ppq--models-data))
|
||||
(name (ppq--aget model 'name))
|
||||
(pricing (ppq--aget model 'pricing))
|
||||
(input-price (or (ppq--aget pricing 'input_per_1M_tokens) 0))
|
||||
(output-price (or (ppq--aget pricing 'output_per_1M_tokens) 0))
|
||||
(nix-str (format " \"%s\" = {\n name = \"%s\";\n cost = [%s %s];\n };"
|
||||
id name (or input-price 0) (or output-price 0))))
|
||||
(kill-new nix-str)
|
||||
(message "Copied: %s" id))))
|
||||
|
||||
(defun ppq--format-created-at (epoch-ms)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue