-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathneopdf-cli.sh
More file actions
executable file
·118 lines (105 loc) · 4.84 KB
/
neopdf-cli.sh
File metadata and controls
executable file
·118 lines (105 loc) · 4.84 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Gum-based interactive wrapper for NeoPDF CLI
# Ensure gum is installed
if ! command -v gum &> /dev/null
then
echo "gum could not be found. Please install it from https://github.com/charmbracelet/gum"
exit
fi
# --- Main Menu ---
echo "Welcome to the NeoPDF interactive CLI!"
COMMAND=$(gum choose "read" "compute" "write" "install")
# --- Read Subcommands ---
if [ "$COMMAND" == "read" ]; then
READ_COMMAND=$(gum choose "metadata" "num_subgrids" "subgrid-info" "subgrid" "git-version" "code-version")
PDF_NAME=$(gum input --placeholder "Enter PDF name")
case $READ_COMMAND in
"metadata")
neopdf read metadata "$PDF_NAME"
;;
"num_subgrids")
neopdf read num_subgrids "$PDF_NAME"
;;
"subgrid-info")
MEMBER=$(gum input --placeholder "Enter member index")
SUBGRID_INDEX=$(gum input --placeholder "Enter subgrid index")
neopdf read subgrid-info "$PDF_NAME" -m "$MEMBER" -s "$SUBGRID_INDEX"
;;
"subgrid")
MEMBER=$(gum input --placeholder "Enter member index")
SUBGRID_INDEX=$(gum input --placeholder "Enter subgrid index")
PID=$(gum input --placeholder "Enter Parton PID")
NUCLEON_INDEX=$(gum input --placeholder "Enter nucleon index (0 if N/A)")
ALPHAS_INDEX=$(gum input --placeholder "Enter alpha_s index (0 if N/A)")
KT_INDEX=$(gum input --placeholder "Enter kT index (0 if N/A)")
neopdf read subgrid "$PDF_NAME" -m "$MEMBER" -s "$SUBGRID_INDEX" --pid="$PID" --nucleon-index "$NUCLEON_INDEX" --alphas-index "$ALPHAS_INDEX" --kt-index "$KT_INDEX"
;;
"git-version")
neopdf read git-version "$PDF_NAME"
;;
"code-version")
neopdf read code-version "$PDF_NAME"
;;
esac
fi
# --- Compute Subcommands ---
if [ "$COMMAND" == "compute" ]; then
COMPUTE_COMMAND=$(gum choose "xfx_q2" "alphas_q2" "xfx_q2_kt")
PDF_NAME=$(gum input --placeholder "Enter PDF name")
MEMBER=$(gum input --placeholder "Enter member index")
case $COMPUTE_COMMAND in
"xfx_q2")
PID=$(gum input --placeholder "Enter Parton PID")
INPUTS=$(gum input --placeholder "Enter inputs (e.g., '1e-5 100')")
neopdf compute xfx_q2 "$PDF_NAME" -m "$MEMBER" --pid="$PID" $INPUTS
;;
"alphas_q2")
Q2=$(gum input --placeholder "Enter Q2 value")
neopdf compute alphas_q2 "$PDF_NAME" -m "$MEMBER" -q "$Q2"
;;
"xfx_q2_kt")
PID=$(gum input --placeholder "Enter Parton PID")
INPUTS=$(gum input --placeholder "Enter inputs (e.g., 'kt x q2')")
neopdf compute xfx_q2_kt "$PDF_NAME" -m "$MEMBER" --pid="$PID" $INPUTS
;;
esac
fi
# --- Write Subcommands ---
if [ "$COMMAND" == "write" ]; then
WRITE_COMMAND=$(gum choose "convert" "combine-npdfs" "combine-alphas" "convert-tmd" "metadata")
case $WRITE_COMMAND in
"convert")
PDF_NAME=$(gum input --placeholder "Enter the LHAPDF set name to convert")
OUTPUT_PATH=$(gum input --placeholder "Enter the output file path for the NeoPDF file")
neopdf write convert "$PDF_NAME" -o "$OUTPUT_PATH"
;;
"combine-npdfs" | "combine-alphas")
INPUT_METHOD=$(gum choose "direct" "file")
if [ "$INPUT_METHOD" == "direct" ]; then
PDF_NAMES=$(gum input --placeholder "Enter PDF set names (space-separated)")
OUTPUT_PATH=$(gum input --placeholder "Enter the output file path for the combined NeoPDF file")
neopdf write $WRITE_COMMAND -n $PDF_NAMES -o "$OUTPUT_PATH"
else
NAMES_FILE=$(gum input --placeholder "Enter the path to the file containing PDF set names")
OUTPUT_PATH=$(gum input --placeholder "Enter the output file path for the combined NeoPDF file")
neopdf write $WRITE_COMMAND -f "$NAMES_FILE" -o "$OUTPUT_PATH"
fi
;;
"convert-tmd")
INPUT_PATH=$(gum input --placeholder "Enter the input configuration file path")
OUTPUT_PATH=$(gum input --placeholder "Enter the output file path for the NeoPDF file")
neopdf write convert-tmd -i "$INPUT_PATH" -o "$OUTPUT_PATH"
;;
"metadata")
FILE_PATH=$(gum input --placeholder "Enter the path to the NeoPDF file")
KEY=$(gum input --placeholder "Enter the metadata key to update")
VALUE=$(gum input --placeholder "Enter the new value for the key")
neopdf write metadata --path "$FILE_PATH" --key "$KEY" --value "$VALUE"
;;
esac
fi
# --- Install Subcommand ---
if [ "$COMMAND" == "install" ]; then
PDF_NAME=$(gum input --placeholder "Enter PDF name")
neopdf install "$PDF_NAME"
fi