package octez-version

  1. Overview
  2. Docs

Source file print_version.ml

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
(*****************************************************************************)
(*                                                                           *)
(* SPDX-License-Identifier: MIT                                              *)
(* Copyright (c) 2024 Nomadic Labs. <contact@nomadic-labs.com>               *)
(*                                                                           *)
(*****************************************************************************)

open Version
open Tezos_version_value.Current_git_info

let print_version version =
  let help_string =
    Format.sprintf
      "This script prints out the current version of \n\
       %s as it is deduced from the git tag of the current branch.\n\
       print_version \
       [--product|--major|--minor|--additional-info|--full|--full-with-commit|--commit|--json]"
    @@ string_of_product version.product
  in
  match Sys.argv with
  | [|_; "--product"|] -> print_endline (string_of_product version.product)
  | [|_; "--major"|] -> print_endline (string_of_int version.major)
  | [|_; "--minor"|] -> print_endline (string_of_int version.minor)
  | [|_; "--additional-info"|] ->
      print_endline (string_of_additional_info version.additional_info)
  | [|_; "--full"|] | [|_|] -> print_endline (to_string version)
  | [|_; "--full-with-commit"|] ->
      print_endline
      @@ Tezos_version_value.Bin_version.simple_version_string version
  | [|_; "--commit"|] -> print_endline abbreviated_commit_hash
  | [|_; "--json"|] -> print_endline (to_json version abbreviated_commit_hash)
  | [|_; "--help"|] -> print_endline help_string
  | _ ->
      print_endline help_string ;
      prerr_endline
        ("invalid argument: " ^ String.concat " " (Array.to_list Sys.argv)) ;
      exit 1
OCaml

Innovation. Community. Security.