ReadProblemInfo 访问题目包信息
(c *cli.Context)
| 119 | |
| 120 | // ReadProblemInfo 访问题目包信息 |
| 121 | func ReadProblemInfo(c *cli.Context) error { |
| 122 | packageFile := c.Args().Get(0) |
| 123 | isDeerPack, err := utils.IsProblemPackage(packageFile) |
| 124 | if err != nil { |
| 125 | return err |
| 126 | } |
| 127 | isZip, err := utils.IsZipFile(packageFile) |
| 128 | if err != nil { |
| 129 | return err |
| 130 | } |
| 131 | // 如果是题目包文件,进行解包 |
| 132 | if isDeerPack { |
| 133 | if c.Bool("gpg") { |
| 134 | g, err := problems.ReadProblemGPGInfo(packageFile) |
| 135 | if err != nil { |
| 136 | fmt.Println(err.Error()) |
| 137 | return nil |
| 138 | } |
| 139 | fmt.Println(g) |
| 140 | } else { |
| 141 | s, _, err := problems.ReadProblemInfo(packageFile, false, false, "") |
| 142 | if err != nil { |
| 143 | return err |
| 144 | } |
| 145 | fmt.Println(utils.ObjectToJSONStringFormatted(s)) |
| 146 | } |
| 147 | } else if isZip { |
| 148 | if c.Bool("gpg") { |
| 149 | g, err := problems.ReadProblemGPGInfoZip(packageFile) |
| 150 | if err != nil { |
| 151 | fmt.Println(err.Error()) |
| 152 | return nil |
| 153 | } |
| 154 | fmt.Println(g) |
| 155 | } else { |
| 156 | s, _, err := problems.ReadProblemInfoZip(packageFile, false, false, "") |
| 157 | if err != nil { |
| 158 | return err |
| 159 | } |
| 160 | fmt.Println(utils.ObjectToJSONStringFormatted(s)) |
| 161 | } |
| 162 | } else { |
| 163 | return errors.Errorf("not a deer-executor problem package file") |
| 164 | } |
| 165 | |
| 166 | return nil |
| 167 | } |
nothing calls this directly
no test coverage detected