Documentation
¶
Overview ¶
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ConvertCmd = &cobra.Command{ Use: "convert", Short: "Convert an item from gibbed to digital_marine or vice versa", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { args[0] = strings.TrimPrefix(args[0], "bl3(") args[0] = strings.TrimSuffix(args[0], ")") bs, err := base64.StdEncoding.DecodeString(args[0]) if err != nil { panic(err) } var dmi item.DigitalMarineItem err = json.Unmarshal(bs, &dmi) if err != nil { i, err := item.Deserialize(bs) if err != nil { cmd.PrintErr("couldn't deserialize item") return } bs, err = json.Marshal(item.GibbedToDm(i)) if err != nil { cmd.PrintErr("couldn't convert item to dm format") return } cmd.Print(base64.StdEncoding.EncodeToString(bs)) return } i := item.DmToGibbed(dmi) bs, err = item.Serialize(i, 0) if err != nil { cmd.Print("error decoding item. invalid serial?") } cmd.Printf("bl3(%s)", base64.StdEncoding.EncodeToString(bs)) }, }
deserializeCmd represents the deserialize command
var DeserializeCmd = &cobra.Command{ Use: "deserialize", Short: "Deserialize a .sav file.", Long: `Deserialize a .sav file. Tries to best-guess the sav file format (profile or character) based on the files name. Override with --format <profile|character> `, Args: cobra.ExactArgs(1), PersistentPreRunE: func(cmd *cobra.Command, args []string) error { if format != "" { if format == "profile" { isProfile = true } else if format == "character" { isProfile = false } else { return errors.New("unknown format option") } } else { isProfile = shared.GuessIsProfileSav(args[0]) } return nil }, Run: func(cmd *cobra.Command, args []string) { f, err := os.Open(args[0]) if err != nil { panic(err) } if isProfile { s, p := profile2.Deserialize(f) r := struct { Sav shared.SavFile Profile pb.Profile }{s, p} bs, err := yaml.Marshal(r) if err != nil { panic(err) } fmt.Print(string(bs)) } else { s, c := character2.Deserialize(f) r := struct { Sav shared.SavFile Character pb.Character }{s, c} bs, err := yaml.Marshal(r) if err != nil { panic(err) } fmt.Print(string(bs)) } }, }
deserializeCmd represents the deserialize command
Functions ¶
Types ¶
This section is empty.